Commands tagged multiple (9)

  • Given some images (jpg or other supported formats) in input, you obtain a single PDF file with an image for every page.


    19
    convert *.jpg output.pdf
    fazen · 2010-10-10 15:41:03 14
  • I needed a way to search all files in a web directory that contained a certain string, and replace that string with another string. In the example, I am searching for "askapache" and replacing that string with "htaccess". I wanted this to happen as a cron job, and it was important that this happened as fast as possible while at the same time not hogging the CPU since the machine is a server. So this script uses the nice command to run the sh shell with the command, which makes the whole thing run with priority 19, meaning it won't hog CPU processing. And the -P5 option to the xargs command means it will run 5 separate grep and sed processes simultaneously, so this is much much faster than running a single grep or sed. You may want to do -P0 which is unlimited if you aren't worried about too many processes or if you don't have to deal with process killers in the bg. Also, the -m1 command to grep means stop grepping this file for matches after the first match, which also saves time. Show Sample Output


    10
    sh -c 'S=askapache R=htaccess; find . -mount -type f|xargs -P5 -iFF grep -l -m1 "$S" FF|xargs -P5 -iFF sed -i -e "s%${S}%${R}%g" FF'
    AskApache · 2009-10-02 05:03:10 7
  • After running firefox -ProfileManager and creating several different profiles, use this command to run multiple Firefox profiles simultaneously.


    5
    firefox -P <profile_name> -no-remote
    mariusbutuc · 2010-08-25 19:14:10 4
  • dsh - Distributed shell, or dancer?s shell ;-) you can put your servers into /etc/dsh/machines.list than you don't have to serperate them by commata or group them in different files and only run commands for this groups dsh -M -c -a -- "apt-get update" Show Sample Output


    4
    dsh -M -c -f servers -- "command HERE"
    foob4r · 2009-08-31 12:08:38 3
  • There's other expansions as well such as `{one,two,three}'. Check the curl docs for more.


    0
    curl -O "http://www.dspguide.com/CH[1-34].PDF"
    CMCDragonkai · 2015-11-26 06:34:40 12
  • If you need to create a profile and are already running Firefox, you don't need to close it to do it. Also, if you don't know the exact name of the profile, this would allow you to pick from a list.


    -2
    firefox -ProfileManager -no-remote
    wdszdwsdzfxdgfrd · 2010-10-08 14:40:18 3
  • A much shorter version of this command.


    -3
    sed -i "s/\s*/ /g;s/\s*$//" input_file
    gitterrost4 · 2011-12-12 10:58:33 6
  • Yeah, there are many ways to do that. Doing with sed by using a for loop is my favourite, because these are two basic things in all *nix environments. Sed by default does not allow to save the output in the same files so we'll use mv to do that in batch along with the sed. Show Sample Output


    -4
    for files in $(ls -A directory_name); do sed 's/search/replaced/g' $files > $files.new && mv $files.new $files; done;
    bassu · 2009-05-07 20:13:07 48
  • This command does the following: - converts any sequence of multiple spaces/tabs to one space only - completely removes any space(s)/tab(s) at the end of each line (If spaces and tabs are mixed in a sequence i.e. [tab][tab][space][tab], you have to execute this command twice!) Show Sample Output


    -4
    sed -i "s/\(\x09\{1,\}\)\|\( \{1,\}\)/ /g;s/\(\x09\{1,\}$\)\|\( \{1,\}$\)//g" brisati.txt
    knoppix5 · 2011-12-12 10:24:03 6

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

Synchronize date and time with a server over ssh
Set Remote Server Date using Local Server Time (push)

Checks throughput between two nodes
This will show the throughput between two nodes. Thanks to szboardstretcher, who posted it here: http://www.linuxquestions.org/questions/linux-networking-3/quick-and-easy-way-to-measure-throughput-between-two-nodes-868998/

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Shows space used by each directory of the root filesystem excluding mountpoints/external filesystems (and sort the output)

Change the homepage of Firefox
Pros: Works in all Windows computers, most updated and compatible command. Cons: 3 liner Replace fcisolutions.com with your site name.

positions the mysql slave at a specific master position
say you want to reinitialize the slave database without resetting the master positions. You stop the slave, dump the master database with --master-data=2 then execute the command on the slave and wait for it to stop at the exact position of the dump. reinit the slave db and start the slave. enjoy.

Replace + Find

python - covert image to base64 string for data URI use
useful if you are using lots of data URI's in your css files

analyze traffic remotely over ssh w/ wireshark
commandline for mac os x

a function to find the fastest DNS server
http://public-dns.info gives a list of online dns servers. you need to change the country in url (br in this url) with your country code. this command need some time to ping all IP in list.


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: