Suppose I'm at a terminal in Linux/UNIX and I run ls
and see the following displayed:
my_file_1.txt my_file_2.txt
Now I want to open the first one in gedit, or maybe it's a folder and I want to enter it.
Is running gedit my_file_1.txt
the fastest way to do this? Suppose the file has a long and awkward name, is there any shortcut along the lines of gedit ls[0]
- where I'm asking gedit to open the first item in the list returned?
If there's not, I won't lose any sleep over it, but if such a shortcut exists I'd make use of it, especially when dealing with lengthy file and folder names.
You could do this:
gedit "$(ls | head -1)"
But probably using filename completion or cutting and pasting with the mouse will be easier.