- 09
- Apr
Shell-Fu is a place for everyone to store those hard to remember *nix commands.
This is so simple yet very useful.
Some of my favorites:
Running a second command with the same arguments as the previous command, use ‘!*’ to repeat all arguments or ‘!:2′ to use the second argument. ‘!$’ uses the final argument.
cd: /home/user/foo: No such file or directory
$ mkdir !*
mkdir /home/user/foo
Make a whole directory tree with one command
Use the -p option to mkdir and make all parent directories along with their children in a single command.
This is a simpler password generator.
Do you have any tips for *nix command line? Let us know in the comments.
Related Posts
Tags: Links, Linux



April 9th, 2008 at 2:21 pm
The site’s sweet - I post one-liners on my site occasionally just because I know I’ll forget them. I added a Bash variant for the Caesar encryption and the /dev/tcp socket connection trick.
Bash Rot-13 encryption:
$ cat file|tr A-Za-z N-ZA-Mn-za-m
Bash Rot-47 encryption:
$ cat file|tr ‘!-~’ ‘P-~!-O’
#!/bin/bash
exec 3/dev/tcp/kinqpinz.info/80
echo -e “GET / HTTP/1.1\nHost: kinqpinz.info;\nConnection: close\n\n”>&3
cat <&3
April 9th, 2008 at 3:58 pm
Repeat a mistyped command with a correction:
$ mkdri blah
bash: mkdri: command not found
$ ^dri^dir
mkdir blah
April 15th, 2008 at 1:11 pm
The password generator in the post won’t work - it should actually be something like:
$ tr -dc A-Za-z0-9_ < /dev/urandom | head -c8
meathive, please collect your Useless Use of Cat award at the podium!
And finally, as a bash tip related to jon’s comment showing how to repeat commands with corrections, this:
$ shopt -s cdspell
enables a feature in bash that will automatically correct directory names that you spell incorrectly when using cd. eg:
[jem:pgl]:~ $ cd public_htlm
public_html
[jem:pgl]:~/public_html $
Hooray for bash.
April 17th, 2008 at 9:39 am
To get the last argument of the previous command you can use the keyboard shortcut Escape and then Period:
‘ESC’ + ‘.’
Also for the same result
‘Alt’ + ‘.’
‘Alt’ - ‘_’ #At same time
Pressing this multiple times will cycle through the last argument of previous commands. This is a readline shortcut.
April 21st, 2008 at 4:22 am
[...] | Hackosis Enlace | [...]
April 21st, 2008 at 4:48 am
[...] | Hackosis Enlace | [...]
May 11th, 2008 at 10:17 pm
Peter, I love awards!