Commands tagged find (410)

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

Functions to display, save and restore $IFS
You can display, save and restore the value of $IFS using conventional Bash commands, but these functions, which you can add to your ~/.bashrc file make it really easy. To display $IFS use the function ifs shown above. In the sample output, you can see that it displays the characters and their hexadecimal equivalent. This function saves it in a variable called $saveIFS: $ sifs () { saveIFS=$IFS; } Use this function to restore it $ rifs () { IFS=$saveIFS; } Add this line in your ~/.bashrc file to save a readonly copy of $IFS: $ declare -r roIFS=$IFS Use this function to restore that one to $IFS $ rrifs () { IFS=$roIFS; }

Simple XML tag extract with sed
Limited, but useful construct to extract text embedded in XML tags. This will only work if bar is all on one line. If nobody posts an alternative for the multiline sed version, I'll figure it out later...

Gets the english pronunciation of a phrase
Sends a string to google tranlator, which converts it to English speech. It's possible to create a nice script to do the job for us, such as #!/bin'bash curl -A "Mozilla" "http://translate.google.com/translate_tts?tl=en&q=$1" > /tmp/speak.mp3 mplayer /tmp/speak.mp3

parrallel execution of a command on remote hosts by ssh or rsh or ...
parrallel execution of a command on remote host by ssh or rsh or ... very useful for cluster management (software update)

Insert a line at the top of a text file without sed or awk or bash loops
Yet another way to add a line at the top a of text file with the help of the tac command (reverse cat).

Block all IP addresses and domains that have attempted brute force SSH login to computer
I use iptables. To rate limit connections. Very easy and no ban lists to manage.

convert unixtime to human-readable with awk
- convert unixtime to human-readable with awk - useful to read logfiles with unix-timestamps, f.e. squid-log: sudo tail -f /var/log/squid3/access.log | awk '{ print strftime("%c ", $1) $0; }

List the size (in human readable form) of all sub folders from the current location
Tested on MacOS and GNU/Linux. It works in dirs containing files starting with '-'. It runs 'du' only once. It sorts according to size. It treats 1K=1000 (and not 1024)

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"

Determine if a command is in your $PATH using POSIX
it is generally advised to avoid using which(1) whenever possible. which(1) is usually a csh(1) script, or sometimes a compiled binary. It's output is highly variable from operating system to operating system, so platform independent scripts could become quite complicated with the logic. On HP-UX 10.20, for example, it prints "no bash in /path /path /path ..."; on OpenBSD 4.1, it prints "bash: Command not found."; on Debian (3.1 through 5.0 at least) and SuSE, it prints nothing at all; on Red Hat 5.2, it prints "which: no bash in (/path:/path:...)"; on Red Hat 6.2, it writes the same message, but on standard error instead of standard output; and on Gentoo, it writes something on stderr. And given all these differences, it's still variable based on your shell. This is why POSIX is king. See http://mywiki.wooledge.org/BashFAQ/081 for more ways on avoiding which(1).


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: