Commands using perl (369)

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

remote-pbzip2 and transfer a directory to local file

Backticks are evil
This is a simple example of using proper command nesting using $() over ``. There are a number of advantages of $() over backticks. First, they can be easily nested without escapes: $ program1 $(program2 $(program3 $(program4))) versus $ program1 `program2 \`program3 \`program4\`\`` Second, they're easier to read, then trying to decipher the difference between the backtick and the singlequote: `'. The only drawback $() suffers from is lack of total portability. If your script must be portable to the archaic Bourne shell, or old versions of the C-shell or Korn shell, then backticks are appropriate, otherwise, we should all get into the habit of $(). Your future script maintainers will thank you for producing cleaner code.

Show a prettified list of nearby wireless APs

Set file access control lists
The file myfile is owned by tom and has read and write permissions for tom. Group and other permissions are empty which make myfile readable and writable only by tom. setfacl enables user tom to give read permission to user john only. The command 'ls -l' shows a '+' sign telling us that file access control list has been setup for myfile.

Recursive find and replace file extension / suffix (mass rename files)
Find recursively all files in ~/Notes with the extension '.md' and pipe that via xargs to rename command, which will replace every '.md' to '.txt' in this example (existing files will not be overwritten).

list block devices
Shows all block devices in a tree with descruptions of what they are.

list files recursively by size

Create subversion undo point
Allows you to save progress without committing. To revert to an undo point, svn revert then apply the undo point with patch. $ svn revert -R . && patch -p0 < .undo/2009-03-27_08:08:11rev57 Similar: http://www.commandlinefu.com/commands/view/373/archive-all-files-containing-local-changes-svn

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"

dump the whole database


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: