Lets say I have multiple files in a directory which all start with the same string
$ ls
fileAA234 fileAA247 fileAA255 fileAA264
fileAA269 fileAA277 fileAA285 fileAA294
Often, when browsing such data files in the command line, I just want to read one, anyone, of these files to see how they are structured.
But if I enter
$ less f
And then hit tab for completion the answer will be
$ less fileAA2
fileAA234 fileAA247 fileAA255 fileAA264
fileAA269 fileAA277 fileAA285 fileAA294
Which doesn't get me all that much closer to open one of the files.
So for now I either use the mouse to mark a random file name and copy paste it to the prompt, or I lean forward and have my poor eyes figure out a unique string to finish typing the filename.
Is their an easy solution for this? I'm just missing something obvious, right?
I'd really like to have something like tab+enter to auto complete and open the first file in the list, like in this case fileAA234
.
Thanks for any help. I imagine there is a way to build a shell script by combining some tools like ls
and head
but I'm still a beginner and haven't found a solution myself yet.