The a
attribute means that the file is append-only: you can't overwrite it or delete it, only append data to it. This is explained in the chattr
man page. Only root can remove the attribute.
The practical consequence is that you can't erase your old history lines. This is presumably intended as a security measure by your system administrator. I'm not completely convinced it's secure, but off the top of my head I can't think of a way to remove some of the file's contents. (It is however easy to bypass the file and run commands without their showing in the history, which is why it's not a particularly useful security measure against competent users — an obvious way being to run the commands from something other than bash.).
Basically, it's the last argument to the previous command.
!$
is the "end" of the previous command. Consider the following
example: We start by looking for a word in a file:
grep -i joe /some/long/directory/structure/user-lists/list-15
if joe is in that userlist, we want to remove him from it. We can either fire up vi with that long directory tree as the argument, or as simply as vi !$
Which
bash expands to:
vi /some/long/directory/structure/user-lists/list-15
(source; handy guide, by the way)
It's worth nothing the distinction between this !$
token and the special shell variable $_
.
Indeed, both expand to the last argument of the previous command. However, !$
is expanded during history expansion, while $_
is expanded during parameter expansion.
One important consequence of this is that, when you use !$
, the expanded command is saved in your history.
For example, consider the keystrokes
(The only characters changed are the $!
and $_
in the middle.)
In the former, when you press Up, the command line reads echo Foo Jar
, so the last line written to stdout is Foo Jar
.
In the latter, when you press Up, the command line reads echo $_ bar
, but now $_
has a different value than it did previously—indeed, $_
is now Jar
, so the last line written to stdout is Jar Jar
.
Another consequence is that _
can be used in other parameter expansions, for example, the sequence of commands
printf '%s ' isomorphism
printf '%s\n' ${_%morphism}sceles
prints isomorphism isosceles
.
But there's no analogous "${!$%morphism}
" expansion.
For more information about the phases of expansion in Bash, see the EXPANSION
section of man 1 bash
(this is called Shell Expansions in the online edition). The HISTORY EXPANSION
section is separate.
Best Answer
This is a special syntax, expanded by bash. It also works for zsh.
According to the bash man page (section HISTORY EXPANSION), the pattern expands as following:
!#
refers to the entire command line typed so far which iscurl http://beyondgrep.com/ack-2.14-single-file > ~/bin/ack && chmod 0755
:
splits between the event designator (this case the entire line) and the word designator (selects a sub-part)3
which selects the third word/argument (counting of words starts at zero), in this case~/bin/ack
.The final command line (usually displayed before executed) is:
curl http://beyondgrep.com/ack-2.14-single-file > ~/bin/ack && chmod 0755 ~/bin/ack
.For details, see the bash manual or very similar the zsh manual