- To: Daniel Bush <dlb.id.au@xxxxxxxxx>
- Subject: Re: [SLUG] Re: useful bash tricks thread
- From: Amos Shapira <amos.shapira@xxxxxxxxx>
- Date: Mon, 9 Feb 2009 15:40:48 +1100
- Cc: slug@xxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=W7V5LzgEOhNvhhYPr/nTiBcEgaOsAKGGmjw7o+reHq4=; b=wYj1qtGcKmONu+cep53/IgKmDWVktznzZ43FV298/I61iRoOeS1QKEXOw9cEbeeagf Fx03j22bTIJB536dpJ+PWYlxcQSpMtm+aej99gO0oYD14QxojbPYA49l30aU2HCMt2m/ LWU5A5Mg2Ddy7bNk8M1nySPq66xFCswHGID8Y=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=pGzpPRpWfDTyhHnoEKApCD9PVWT10xHLjK5xR30WdAwHdLDgi8pMunBc2UyWmyHM5G Hk2pIaMJMZMAcFKMRmdiII+OUqoIau+X/766L79tsQcny9m0tN5piQT9mJqObbLFywRg VpPgLrj4xUEOHmDvcchHnyxeuX4U6ghvzZ3N4=
At the risk of being called an oldie, I keep using !-notation since
the early tcsh days. E.g. "!$" or !:2-3.
You can also use things like
!less:*
to fetch the parameters of the latest less command.
I can't type alt-> because alt-shift is my keyboard language-switching
combination, so I don't know how this compares with good old
bang-notation.
Other useful stuff:
^x^y will replace the first "x" on the previous line by "y". Use a
third "^" after "y" if it contains space. It's actually a short for
"!!:s/x/y/"
Where !!:s comes handy is to replace globally: !!gs/x/y/ will replace
ALL of the "x"'s on last line by "y"'s.
Then again - you can type "!command" or "!-3" to use another history
line as a basis.
And one last thing, related to security - if you type a sensitive
string on the command line and get it into your history, use "history
-d" to delete this line.
Cheers,
--Amos