Various Linux commands and examples

Convert ogg files to mp3

for i in `ls *.ogg`;do avconv -i $i -ab 128k $i.mp3;done

After remove .ogg from file names

rename 's/.ogg//' *.mp3

Convert mp3 files to ogg

for i in `ls *.mp3`;do avconv -i $i -ab 128k -acodec libvorbis $i.ogg;done

Concatenate several pdf files

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=concatenated_files.pdf *.pdf

Rotate the pages of a pdf file

Rotate all pages 90 degrees to the left

pdftk A=file.pdf shuffle AL output rotatedFile.pdf

Rotate odd pages to the left and even pages to the right

pdftk A=file.pdf shuffle AoddL AevenR output rotatedFile.pdf

Bash iteration to get a number of images from a website

This script extracts 100 images from a remote site

User agent string passed to wget is used to avoid Forbidden error

for i in {1..100}; do wget -U 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20070802 SeaMonkey/1.1.4'$i.png; done


Limit download speed

wget --limit-rate=100k

Identifying as desktop browser

wget -U 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20070802 SeaMonkey/1.1.4'


Exclude directory

grep --exclude=dirToExclude 'searchString' *

Exclude binary files

grep -I 'searchString' *