[Nottingham] Shell programming
Martin
martin at ml1.co.uk
Sat Dec 18 15:01:44 GMT 2004
Simon Huggins wrote:
[...]
>
> Not commands but I've started using !!$ and !!$:t a lot now in bash.
>
> !!$ means the last argument from the last command.
> !!$:t means the filename from the last argument from the last command.
>
> See man bash for more details but it's useful when you edit something
> and then want to do something with the file you were editing.
>
> You can also do stuff like:
> $ vim /foo/bar/baz
> $ ls something_else
> ls: something_else: No such file or directory
> $ !vim:$
> ls /foo/bar/baz (bash actually prints this to
> stdout before running it)
> ls: /foo/bar/baz: No such file or directory
>
> And if you're really showing off:
> $ ls /foo/bar/baz
> ls: /foo/bar/baz: No such file or directory
> $ ls !!$:s/foo/wibble/
> ls /wibble/bar/baz
> ls: /wibble/bar/baz: No such file or directory
>
> I mostly only remember !!$ and !!$:t though as they're the most useful
> to me but there's a lot you can do with bash's history and event magic.
You must have been listening very carefully in my first bash hints 'n'
tips talk!
From the second talk, see:
http://shoe.bocks.com/nlug/2004-Feb/4511.html
And my latest tweaked tips file "/etc/profile.d/mlbashtips.sh" is
attached for anyone interested.
Cheers,
Martin
--
----------------
Martin Lomas
martin at ml1.co.uk
----------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mlbashtips.sh
Type: text/x-sh
Size: 5043 bytes
Desc: not available
Url : http://mailman.lug.org.uk/pipermail/nottingham/attachments/20041218/ec2ac787/mlbashtips.bin
More information about the Nottingham
mailing list