2020-11-09 A nice tip about Bash redirection

Some time ago I had a minor epiphany about Bash redirection. I needed to perform the same command for various files, and each time redirect its results to some file. Normally, I would say

command file_name >> log_file

then press the up key to bring the last command from the history, change the file_name, press Enter and so on.

However, as the documentation says,
The […] redirection operators may precede or appear anywhere within a simple command […].
This means that I can also say

>> log_file command file_name

and then, after pressing up, I won’t have to back up by the log_file and the redirection to get to the file_name I need to change.

Quite useful!

CategoryEnglish, CategoryBlog