Commands using cat (514)

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

Get IP address from domain
I'm not sure how reliable this command is, but it works for my needs. Here's also a variant using grep. nslookup www.example.com | grep "^Address: " | awk '{print $2}'

Speed up builds and scripts, remove duplicate entries in $PATH. Users scripts are oftern bad: PATH=/apath:$PATH type of thing cause diplicate.
Thanks to the authors of: $ awk '!x[$0]++' and the author of: $ joinargs() { (local IFS="$1"; shift && echo "$*") } and others, we can have a fast Linux or android. IMPORTANT if you find a priority order problem in PATH you can push a path directory to the front without duplication as follows: $ PATH=/bin:$PATH then ... Check duplication with: $ echo $PATH|tr : '\n'|sort|uniq -d Finally do a very neat line by line list of $PATH: $ echo "${PATH//:/$'\n'} The speed up is very noticeable for android, and builds on Linux Ubantu are much faster with make and scripts. I will update the command on request. Timothy from SONY

Reduce PDF size

Grabs a random image from "~/wallpapers" and sets as the background
don't bother spawning a bc process or counting the number of options, just pick a random one. 'sort -R' sorts randomly, so pick the top one.

List of reverse DNS records for a subnet
This command uses nmap to perform reverse DNS lookups on a subnet. It produces a list of IP addresses with the corresponding PTR record for a given subnet. You can enter the subnet in CDIR notation (i.e. /24 for a Class C)). You could add "--dns-servers x.x.x.x" after the "-sL" if you need the lookups to be performed on a specific DNS server. On some installations nmap needs sudo I believe. Also I hope awk is standard on most distros.

Print all lines between two line numbers
This command uses awk(1) to print all lines between two known line numbers in a file. Useful for seeing output in a log file, where the line numbers are known. The above command will print all lines between, and including, lines 3 and 6.

dmesg with colored human-readable dates
Use sed to color the output of a human-readable dmesg output

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Concatenate video files to YouTube ready output
Takes two input video files and an external audio track and encodes them together to an MPEG-4 DivX output video file with the correct size ready for uploading.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"


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: