Friday, July 4, 2008

[Bash] Populate command line with occurrences

Little tip for bash users:

Let's say you want to delete all files in a directory that starts by 'exam' except one. I would use 'rm' and put all the file names I want to delete manually as there is just one I want to keep.
By typing:

rm exam[ESC + *]

the command [ESC + *] will populate the argument line with all occurrences of 'exam'.

And now, you can remove the file you want to keep from the list.

If you're lucky and the file you want to keep is the last one, a simple [Ctrl + W] will remove the last argument passed in the command line.

The tip was found here(in french)

No comments: