Commands tagged perl (190)

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

Open multiple tabs in Firefox from a file containing urls
this will open a new tab in firefox for every line in a file the sleep is removable but i found that if you have a large list of urls 50+, and no sleep, it will try to open all the urls at once and this will cause them all to load a lot slower, also depending on the ram of your system sleep gives you a chance to close the tabs before they overload your ram, removing & >2/dev/null will yield unpredictable results.

Extract extention of a file

Remount a usb disk in Gnome without physically removing and reinserting
Remounts a usb disk /dev/sdb, without having to physically remove and reinsert. (Gnome desktop)

Empty Bind9 cache
Occasionally, to force zone updating, cache flush is necessary. The use of this command is better than restart the Bind9 process.

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"

Silently Execute a Shell Script that runs in the background and won't die on HUP/logout
This command runs your shell script in the background with no output of any kind, and it will remain running even after you logout.

Compress and store the image of a disk over the network
Create an image of "device" and send it to another machine through the network ("target" and "port" sets the ip and port the stream will be sent to), outputting a progress bar On the machine that will receive, compress and store the file, use: $nc -l -p | 7z a -si -m0=lzma2 -mx=9 -ms=on Optionally, add the -v4g switch at the end of the line in order to split the file every 4 gigabytes (or set another size: accepted suffixes are k, m and g). The file will be compressed using 7z format, lzma2 algorithm, with maximum compression level and solid file activated. The compression stage will be executed on the machine which will store the image. It was planned this way because the processor on that machine was faster, and being on a gigabit network, transfering the uncompressed image wasn't much of a problem.

Get the size of all the directories in current directory
OSX's BSD version of the du command uses the -d argument instead of --max-depth.

Find recursively, from current directory down, files and directories whose names contain single or multiple whitespaces and replace each such occurrence with a single underscore.
Note the g for global in the perl expression; without it, only the first occurrence in the name would be replaced.

Unix commandline history substitution like ^foo^bar BUT for multiple replacements
#1 You invoked a command chain. #2 You globaly replace the scriptnames and execute them direct #3 The new executed command chain [# ^foo^bar] would only replace the firts match [foo] with [bar].


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: