As far as default interactive shell bash
and scripting shell dash
goes, you can use $_
to recall last argument of the last command.
$ echo "Hello World"; echo same "$_"
Hello World
same Hello World
csh and tcsh have history references, specifically for the last word of the command, you can use !$
, and for individual arguments - !:<index>
:
~% echo foo bar
foo bar
~% echo !$
echo bar
bar
% echo bar baz
bar baz
% echo !:1
echo bar
bar
In general, it's just better to assign whatever is objectA
to a variable, and use it in multiple commands, loops, etc. Alternatively, a function could be a choice:
$ foo(){ echo "$@"; stat --print="%F\n" "$@";}
$ foo testdir
testdir
directory
&
will send the "touch" command into the background. If you intended "open the editor if touch succeeded", then you want&&
instead