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

purge all packages marked with 'rc'
After you install/remove lots of packages, there are many packages marked with 'rc'. This script help you to purge these packages, it will save some spaces from your disk.

Get your local IP regardless of your network interface
Shows only IP-addresses of ifconfig except 127.0.0.0/8. I fixed the script to work on more systems and configs short info /inet/!d; #grep inet /127.0/d; # grep -v 127.0 /dr:\s/d; # grep -v dr: s/^.*:\(.*\)B.*$/\1/ # remove everything exept between : and B

Convert one file from ISO-8859-1 to UTF-8.
Nothing fancy it just converts one file from one character encoding into another one.

Lines per second in a log file

Exclude inserting a table from a sql import
Starting with a large MySQL dump file (*.sql) remove any lines that have inserts for the specified table. Sometimes one or two tables are very large and uneeded, eg. log tables. To exclude multiple tables you can get fancy with sed, or just run the command again on subsequently generated files.

Better git diff, word delimited and colorized
I've been using colordiff for years. wdiff is the new fav, except its colors. Word delimited diffs are more interleaved, easing the chore of associating big blocks of changes.

Get International Space Station sighting information for your city
This command outputs a table of sighting opportunities for the International Space Station. Find the URL for your city here: http://spaceflight.nasa.gov/realdata/sightings/

Sort lines using the Xth characted as the start of the sort string
Tells sort to ignore all characters before the Xth position in the first field per line. If you have a list of items one per line and want to ignore the first two characters for sorting purposes, you would type "sort -k1.3". Change the "1" to change the field being sorted. The decimal value is the offset in the specified field to sort by.

Execute a command, convert output to .png file, upload file to imgur.com, then returning the address of the .png.
My key is the anonymous one, is good for 50 post an hour with a maximun number of uploads a day, probably will run out, if that happend you can get a free key at the site.

Compute newest kernel version from Makefile on Torvalds' git repository
The platform-agnostic version of https://www.commandlinefu.com/commands/view/25276/compute-newest-kernel-version-from-makefile-on-torvalds-git-repository because macOS doesn't have wget installed


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: