commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
After you execute a command (or shell script) in the background using
&, if you logout from the session, the command will get killed. To avoid
that, you should use nohup as shown below.
Convert long list of ' ' to a single space. Compress space and other characters.
Display the 1st field (employee name) from a colon delimited file
The following displays only the entries that are duplicates.
Uniq command is mostly used in combination with sort command, as
uniq removes duplicates only from a sorted file. i.e In order for uniq to
work, all the duplicate entries should be in the adjacent lines.
ls -al gives all files, sort +4n sorts by 5th field numerically
Sort using kth column using : delimiter
Translates first set into second set
Join command combines lines from two files based on a common field.
This will be very helpful when you are debugging shell scripts, where
you don?t want to display the echo statement and interested in only
looking at the error messages. Similarly use 2> to supress error messages
This pattern matches empty lines in the file and -c gives the count
Use shopt -s cdspell to correct the typos in the cd command
manage directory stack
switch to previous directory or toggle
Creates a directory and then cds into it directly
While logged into ssh, type ~s to see stats of ssh
Suspend ssh session
Sometimes it is necessary to view debug messages to troubleshoot any
SSH connection issues. pass -v (lowercase v) option to the ssh as shown
below to view the ssh debug messages.