I was watching the this video tutorial and around the 1:40 mark the author issues the following command. It creates two files, under the recently created folder.
touch !!:2/{package.json,index.js}
Can someone please explain what !!:2 means? and why it didn't create the two files under all the folders?
in bash you can use !! to repeat the previous command line. A typical usage is:
do some command that needs root permissions
# this fails, so:
sudo !!
which will expand to:
sudo do some command that needs root permissions
the expression !!:2 means: take the third (0-based indexing) word from the previous command line.
example to illustrate:
$ echo these are some words in a sentence
these are some words in a sentence
$ echo !!:2
echo are
are
NOTE that this is extremely error prone, especially with the 0-based indexing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With