How is it possible to get an addressable list of files in the terminal, that can be used later on. In the terminal it would be nice having the following work flow by using a tool (like ls):

1:Population and Other Problems (China National Publications).pdf
2:Weeds in a Changing World (British Crop Protection Council).pdf
3:The Joy of Chickens (Prentice Hall)- 1.pdf
5:The Joy of Chickens (Prentice Hall)- 2.pdf
6:The Weather God ist not nice.pdf
8:The Joy of Chickensoup.pdf

Then I could simple do for example:

rm 5:

Instead of having to write:

rm 'The Joy of Chickens (Prentice Hall).pdf'

By using - as suggested by Pilot6 - Tab it is possible to have autocomplete, but if you have similiar names you still have to write quite much. Is there a other lazy way?

  • 2
    You do not have to write the full file name. You can use autocomplete. Type rm T and press Tab. – Pilot6 Feb 1 '17 at 18:35
  • I did not know that - sorry and thank you! I'll change the question a bit. – TimK Feb 1 '17 at 19:06
  • The lazy way is mc. It works in terminal. You do not have to type anything. – Pilot6 Feb 1 '17 at 19:23
  • Well, after your input I could do a proper search myself and I found this: askubuntu.com/questions/280327/… – TimK Feb 1 '17 at 19:32

I do not see that any new tool is needed. There are enough tools for this.

  1. Use autocomplete in a terminal. Type rm T and press Tab. You wil get the full file name. Maybe you will need 2-3 first letters if there are other files starting with T.

  2. You can install Midnight Commander and interactively select files for deletion in a terminal.

It can be installed by sudo apt install mc. To start it run mc.

Select any number of files to delete by Insert and delete by F8.

There may be lots of other ways of doing this.

  • Thank you very much for your kind answer, it is useful for me. :-) – TimK Feb 1 '17 at 19:39

The answer I marked as correct is answering my original question.

But I also found a better solution for me:

How to make terminal autocomplete when there are several files/directory?

You can use just use the Tab-Key to “tab” through the results as list. This is absolutely awesome. (You can also go back in the list)

Edit: Alternative you could switch to Fish-Shell. It has more function for autocomplete and I really like it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.