When reading the content of a script, I found something like:
echo "An Example" > !$
So I wonder what does !$
mean in bash .
When reading the content of a script, I found something like:
echo "An Example" > !$
So I wonder what does !$
mean in bash .
From
man bash
(somewhere after the line 3813):So, the
!$
will recall the last argument from the last command from history.Here are some examples and equivalents:
All of these will work only inside of an interactive shell. But if you use that command from your question inside of a script as you said that you sow it, then the things are different: when you run the script, this will start in a new shell, a non-interactive shell, so the history expansion doesn't has any effect in this case and so the command:
creates the file
!$
if not present (otherwise overwrites it) and writeAn Example
into it.Well i found that !$ means last argument so for an example :
Here the argument is /tmp/file1 , so !$ replaced
/tmp/file1
in echo example .If then you type the command
du -b !$
, the output will be the disk usage in bytes for/tmp/file1