The Command Line - Less to Remember
The Linux command line can be quite complex at times. Many commands, options, switches to remember. For example, listing only the first 3 files, with their details:
$ ls -l
-rwxrwxrwx 1 mio mio 18824 Sep 5 17:43 apt
-rwxrwxrwx 1 mio mio 704984 Aug 17 2023 gawk
-rwxrwxrwx 1 mio mio 146088 Jun 26 2024 sftp
What if I want it sorted by name in reverse?
$ ls -lr
-rwxrwxrwx 1 mio mio 146088 Jun 26 2024 sftp
-rwxrwxrwx 1 mio mio 704984 Aug 17 2023 gawk
-rwxrwxrwx 1 mio mio 18824 Sep 5 17:43 apt
But only those with a name containing the letter "t", again sorted by name in reverse. This becomes a bit more complicated:
$ find . -name "*t*" -print0 | xargs -0 ls -lr
-rwxrwxrwx 1 mio mio 146088 Jun 26 2024 ./sftp
-rwxrwxrwx 1 mio mio 18824 Sep 5 17:43 ./apt
AI To The Rescue
If you don't remember the switch to sort by name in reverse, you can use a LLM instead:
领英推荐
$ ls -l | llm "sorted by name in reverse"
Based on the details provided, you want the files sorted by their names in reverse order. Here is the sorted list:
-rwxrwxrwx 1 mio mio 146088 Jun 26 2024 sftp
-rwxrwxrwx 1 mio mio 704984 Aug 17 2023 gawk
-rwxrwxrwx 1 mio mio 18824 Sep 5 17:43 apt
And the complicated command:
$ ls -l | llm "keeping only the files with the letter 't' in the name, sorted by name in reverse"
You need to keep only the files with 't' in their names and sort them in reverse order by name:
1. Files with the letter 't':
- apt
- sftp
2. Now, sort these file names in reverse order:
- sftp
- apt
So, your sorted list of files meeting the criteria would be:
-rwxrwxrwx 1 mio mio 146088 Jun 26 2024 sftp
-rwxrwxrwx 1 mio mio 18824 Sep 5 17:43 apt
Now, all that is left is to cleanup the "helpful insights" the model left behind in the answer.
Would I use this? Probably not on a daily basis, but it looks promising.
Will we forget about the command line in a couple of years? Probably not, since it provides one of the most reliable and consistently repeatable ways of doing tasks on a computer.
I used https://github.com/simonw/llm. There are other similar programs, but this looked like the best to me at this time.
Will try it.