Using history command in bash script

Alan Pope alan.pope at canonical.com
Fri Feb 24 12:15:18 UTC 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 24/02/12 12:12, Johnny Rosenberg wrote:

> I'm trying to make a bash script that creates an alias for my last 
> command and save it in my .bash-aliases file (which is launched
> from the .bashrc file), so I need some way to know what my latest
> command was.
> 

You may not know but "!!" already is an alias for the last command:-

alan at deep-thought:~$ cowsay moo
 _____
< moo >
 -----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
alan at deep-thought:~$ !!
cowsay moo
 _____
< moo >
 -----
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Cheers,
- -- 
Alan Pope
Engineering Manager

Canonical - Product Strategy
+44 (0) 7973 620 164
alan.pope at canonical.com
http://ubuntu.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPR39QAAoJEMx6UFtfvV4wBAwH/05ziK+8RCmvh8z8ic0lpsMz
uIBOUBY6vRVBrt/t8143cF9iPqSyjXtvx/pQynewmWBESir4aZPZWGCtMD9Bmzax
KvgcWRbDdaYJzFTogNH5zedmsQWYCVbslvpeQNPY6DMY3w1M+ECdwBLHnLgP+RZs
Lsn7ECrbCNS7IHznkox5LYRjbONSK7aZGb7HRbUCi9gBtlvgBcxWE219/E0V7kQF
yvNnH318J3nE1lvK43NVQmHWPuYjf4mXKYymTugUVPnRmdK+KyoDaubTwxzwxTft
gN3YgjpnCgKnttUTWUkbkbnrRZvRtIDjGM5ZGLwePVai3TeiXfjong08pBUktdw=
=osAV
-----END PGP SIGNATURE-----




More information about the ubuntu-users mailing list