Commands using grep (1,935)

What's this?

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.

Share Your Commands


Check These Out

print contents of file from line 1 until we match regex
Start printing the contents of filename to stdout, until a matching line to regex is found, then stop.

put current directory in LAN quickly

"What the hell is running on?!" Easily snoop your system's RAM consumption
Works on most unixes, on OpenBSD replace the "-g" parameter at the sort with a "-n".

Find usb device
I often use it to find recently added ou removed device, or using find in /dev, or anything similar. Just run the command, plug the device, and wait to see him and only him

autossh + ssh + screen = super rad perma-sessions
Only useful for really flakey connections (but im stuck with one for now). Though if youre in this situation ive found this to be a good way to run autossh and it does a pretty good job of detecting when the session is down and restarting. Combined with the -t and screen commands this pops you back into your working session lickety split w/ as few headaches as possible. And if autossh is a bit slow at detecting the downed ssh connection, just run this in another tab/terminal window to notify autossh that it should drop it and start over. Basically for when polling is too slow. kill -SIGUSR1 `pgrep autossh`

check open ports without netstat or lsof

IP addresses connected to port 80
IP addresses and number of connections connected to port 80.

Validating a file with checksum
Makes sure the contents of "myfile" are the same contents that the author intended given the author's md5 hash of that file ("c84fa6b830e38ee8a551df61172d53d7").

Google URL shortener
Shorter and made into a function.

Create multiple subfolders in one command.
Instead of typing separate commands to create various subfolders, we can create multiple subfolders by listing them between brackets and separated by commas.


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: