Using history command in bash script

Johnny Rosenberg gurus.knugum at gmail.com
Fri Feb 24 12:56:40 UTC 2012


2012/2/24 Alan Pope <alan.pope at canonical.com>:
> -----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:-

Yes, but it doesn't seem like I can use it in a script, can I? At
least I failed.


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ


>
> 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-----
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users




More information about the ubuntu-users mailing list