Monthly Archive for December, 2006

Usefull Commands: a Synthesis

Here is the list of all posts of the “Usefull Commands” theme. If you don’t know what this is all about, please read the introduction.

Rugg 0.2.3 for Mandriva 2007

I’ve build a new RPM of Rugg 0.2.3 for Mandriva 2007. You can find it in my Mandriva repository.

Website Backup Script Updated: Take Care of Hidden Files now.

I’ve updated my website-backup python script.

Change log:

  • Use set ftp:list-options -a command to force lftp to download hidden files (like .htaccess and so on).
  • Use --force parameter to allow auto-deletion of multiple outdated rdiff-backup increments.
  • Defensive incremental backup policy: keep 32 last backups instead of 32 days of backup.

I also added a debug mode as suggested by Sacha.

Usefull Commands: Image Processing

  • Convert several files from a format to another:
    convert img_*.bmp img_%04d.png
    
  • Resize images of the current folder to progressive jpeg. Resized images will not be greater than 600×600, but the aspect ratio will be respected:
    convert -resize 600x600 -sharpen 1 -interlace Line * pict%04d.jpg
    
  • Create a PNG image of a rendered html page:
    kwebdesktop 1024 768 capture.png http://www.linuxfr.org
    
  • Remove all metadata of a JPEG file:
    exiftool -all= image.jpg
    

Usefull Commands: Text and Documents Processing

  • Text replacement:
    sed 's/string to replace/replacement string/g' original-file.txt > new-file.txt
    
  • Replace all occurrences of str1 by str2 in all files below the /folder path:
    find /folder -xdev -type f -exec sed -i 's/str1/str2/g' "{}" \;
    
  • In place charset transcoding:
    recode utf-8..latin-1 utf8text.txt
    
  • Get the current date in english:
    env LC_TIME=en date +"%a %b %d %Y"
    
  • Get the number of seconds since epoch:
    date +%s
    
  • Merge 2 PDF documents:
    pdftk doc1.pdf doc2.pdf cat output newdoc.pdf
    
  • Same as above, but for all PDFs of the current folder. This also have the nice side effect of removing all DRMs :) :
    gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=bigfile.pdf ./*
    
  • VIM: no autoindent on paste.
  • a list of sed one-liners.