In the following Bash command, what is the meaning of: !#:* !#:1
echo "This is a sentence." !#:* !#:1- >text3
It's using bash's history substitution mechanism.
Specifically, !#
refers to the current line (up to but not including the location of the !#
itself). !#:*
is the part of that line after the command name (so, in this case, "This is a sentence."
). !#:1-
is the same as !#:*
except that it omits the last word (so it doesn't include the second copy of "This is a sentence"
that we just added via the !#:*
).
The end result is a line with three copies of This is a sentence.
echoed into a file named text3
.
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