instead of writing: if [[ "$1" == "$2" ]]; then echo "$1 is equal $2" else echo "$1 differs from $2" fi do write: [[ "$1" == "$2" ]] && echo "$1 is equal $2" || echo "$1 differs from $2"
Use this command to find out a list of committers sorted by the frequency of commits. Show Sample Output
Sends SIGINFO to the process. This is a BSD feature OS X inherited. You must have the terminal window executing dd selected when entering CTRL + T for this to work. Show Sample Output
Test scenario: * Open xterm (or konsole, ...) * Start xeyes with: ( xeyes & ) * Close the xterminal The xeyes process should be still running.
alternative for "echo rm *.txt". Just doubletab the command you are willing to use and it will show you the affected files. Show Sample Output
Open up vi or vim at the first instance of a pattern in [file]. Useful if you know where you want to be, like "PermitRootLogin" in sshd_config. Also, vi +10 [file] will open up a file at line 10. VERY useful when you get "error at line 10" type of output.
Add this to a fiend's .bashrc. PROMPT_COMMAND will run just before a prompt is drawn. RANDOM will be between 0 and 32768; in this case, it'll run about 1/10th of the time. \033 is the escape character. I'll call it \e for short. \e7 -- save cursor position. \e[%d;%dH -- move cursor to absolute position \e[4%dm \e[m -- draw a random color at that point \e8 -- restore position.
Halt script progress until a key has been pressed. Source: http://bash-hackers.org/wiki/doku.php/mirroring/bashfaq/065
Yeah I know it's been up here a million times, but this service is a really clean and nice one. Nothing but your IP address on it. Actually I was to write something like this, and noticed this on appspot... ;) Show Sample Output
Usage: clfavs username password num_favourite_commands file_in_which_to_backup
this command will send a message to the socket 25 on host 192.168.1.2 in tcp. works on udp and icmp understand only IP address, not hostname. on the other side (192.168.1.2), you can listen to this socket and test if you receive the message. easy to diagnose a firewall problem or not.
doesn't require "at", change the "2h" to whatever you want... (deafult unit for sleep is seconds)
Uses the last argument of the last executed command, and gets the directory name from it. Use $!:t for the filename alone, without the dirname. Show Sample Output
OK, not the most useful but a good way to impress friends. Requires the "display" command from ImageMagick.
You will need libnotify-bin for this to work:
sudo aptitude install libnotify-bin
Pipe any command through figlet to make the output more awesome. Example:
ls | figlet
Show Sample Output
List all file opened by a particular command based on it's command name. Show Sample Output
Nicely display permissions in octal format and filename for a given directory Show Sample Output
recursively traverse the directory structure from . down, look for string "oldstring" in all files, and replace it with "newstring", wherever found
also:
grep -rl oldstring . |xargs perl -pi~ -e 's/oldstring/newstring'
Redirect the local port 2000 to the remote port 3000. The same but UDP:
nc -u -l -p 2000 -c "nc -u example.org 3000"
It may be used to "convert" TCP client to UDP server (or viceversa):
nc -l -p 2000 -c "nc -u example.org 3000"
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: