In linux command cd, after make a dir, I can use "cd !!:1" to enter it, but what exactly does !!:1 mean, I can't search it by google, because it include special chars.
Asked
Active
Viewed 424 times
2 Answers
5
That will change directory to the first argument of the previous command
For example
% ls foo bar
% cd !!:1
is equivalent to
% ls foo bar
% cd foo
Also !!:0
gives you the actual command (less arguments), !!:2
the second argument, !!:$
the last argument, and !!
the whole command line.

Bull
- 11,771
- 9
- 42
- 53
3
!!
is short hand for the previous command. The :1
goes to the second parameter in the command, which in your previous command was the directory name.
One of my favorite command-line shortcuts is sudo !!

Blake G
- 581
- 7
- 24