Commands using head (314)

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

Copy from host 1 to host 2 through your host

Get IPv4 of eth0 for use with scripts
I've been using it in a script to build from scratch proxy servers.

check open ports without netstat or lsof

Compare an archive with filesystem
and you quickly know the files you changed

Renames all files in the current directory such that the new file contains no space characters.
This is a better version, as it does no command piping, uses for instead of while loops, which allows for a list of files in the current working directory to be natively processed. It also uses the -v/verbose option with mv to let you know what the command is doing. While the command does exactly the same in a better way, I would modify the sed option to replace spaces with underscores instead, or dashes. Please note that you'll receive errors with this command as it tries to rename files that don't even have spaces. This is an alternative to: http://www.commandlinefu.com/commands/view/8761/renames-all-files-in-the-current-directory-such-that-the-new-file-contains-no-space-characters.

Use -t when using find and cp
-t, --target-directory=DIRECTORY (copy all SOURCE arguments into DIRECTORY).

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"

Press Any Key to Continue
Halt script progress until a key has been pressed. Source: http://bash-hackers.org/wiki/doku.php/mirroring/bashfaq/065

search office documents for credit card numbers and social security number SSN docx xlsx
# CC with SSN dash ( low false positive only match ###-##-#### not any 8digi number ) $ find . -iname "*.???x" -type f -exec unzip -p '{}' '*' \; | sed -e 's/]\{1,\}>/ /g; s/[^[:print:]]\{1,\}/ /g' | egrep "\b4[0-9]{12}(?:[0-9]{3})?\b|\b5[1-5][0-9]{14}\b|\b6011[0-9]{14}\b|\b3(?:0[0-5]\b|\b[68][0-9])[0-9]{11}\b|\b3[47][0-9]{13}\b|\b[0-9]{3}-[0-9]{2}-[0-9]{4}\b" $ rmccurdyDOTcom

Print Memory Utilization Percentage For a specific process and it's children
Change the name of the process and what is echoed to suit your needs. The brackets around the h in the grep statement cause grep to skip over "grep httpd", it is the equivalent of grep -v grep although more elegant.


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: