Commands tagged grep (409)

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

generate random number

Check for Firewall Blockage.
This is just one method of checking to see if an IP is blocked via IP tables or CSF. Simple and to the point. Replace xx.xx.xx.xx with the IP you wish to check.

Get line number 12 (or n) from a file
Extracts only file number 12 from file. It's meant for text files. Replace 12 with the number you want. First line starts at 1 not 0. We use q on next line so doesn't process any line more.

a for loop with filling 0 format, with seq
seq allows you to format the output thanks to the -f option. This is very useful if you want to rename your files to the same format in order to be able to easily sort for example: $for i in `seq 1 3 10`; do touch foo$i ;done And $ls foo* | sort -n foo1 foo10 foo4 foo7 But: $for i in `seq -f %02g 1 3 10`; do touch foo$i ;done So $ls foo* | sort -n foo01 foo04 foo07 foo10

create a temporary file in a command line call
Sometimes you have a script that needs and inputfile for execution. If you don't want to create one because it may contain only one line you can use the `

show the difference

Lists all listening ports together with the PID of the associated process
The PID will only be printed if you're holding a root equivalent ID.

Show current working directory of a process

Set access and modification timestamps of a file using another one as reference
atime and mtime timestamps of $FILE2 is changed according to the ones of $FILE1. If $FILE2 doesn't exist is created.

monitor the last command run


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: