Search This Blog


Bash Argument Recall

If we're looking a the permissions of a file using ls -l
ls -l /path/to/file
Then we decide we want to change permissions of that file. Instead of retyping out the entire path again we can use
chmod +x (then press 'Esc+.' to fill out the path /path/to/file)

Alternatively there is a bash argument called !$ which stores the value of the previous argument of the command so you could also use
chmod +x !$
To achieve the same result as the previous command.

Another interesting method is using bash history again to specify which argument you would like from the previous listing
!:* - all arguments
!:n - where 'n' is the n'th argument 
1:$ - where '$' is the last argument

No comments:

Post a Comment