#python -m  SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...


### create random size temporary files
dd if=/dev/zero  of=`mktemp -p /home/rgouveia/tmp/delete/repo/testes` bs=${RANDOM} count=1 

### for loop in ksh for 10x
for d in `jot 10`; do echo $d ; done;

### remove blank lines
sed '/^$/d' <INPUT_FILE>

### remove ^M (dos control character)
sed 's/'"$(printf '\015')"'$//g'  <INPUT_FILE>

### remove % from line
echo 100% | sed  "s/%//"

### remove EXIF data with ImageMagik
/usr/local/bin/mogrify -strip image.jpg | /usr/local/bin/identify -verbose image.jpg | grep -i exif

### rename all files with spaces to files with '_'
find . -name '* *' | while read file;do target=`echo "$file" | sed 's/ /_/g'`;echo "Renaming '$file' to '$target'";mv "$file" "$target";done;

### convert PDF files to text with xargs (linux)
ls *.pdf | xargs -I{} pdftotext {}

### merge PDFs with ghostscript

gs -dEmbedAllFonts=true -sPAPERSIZE=a4 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf -dBATCH pg1.pdf pg2.pdf pg3.pdf pg4.pdf pg5.pdf pg6.pdf

### alter PDF title and author
gs -dEmbedAllFonts=true -sPAPERSIZE=a4 -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=new.pdf -dBATCH old.pdf pdfmarks
### file pdfmarks:
[ /Title ()
  /Author ()
  /Creator ()
  /Producer ()
  /DOCINFO pdfmark


### merge PDFs with pdftk

pdftk 1.pdf 2.pdf cat output merged.pdf

### JPGs->PDF ImageMagick
convert *.jpg foo.pdf

### strip PDF Metadata (from http://randomdeterminism.wordpress.com/2010/08/18/stripping-metadata-from-pdf-files)
pdftk $PDF  dump_data | sed -e 's/\(InfoValue:\)\s.*/\1\ /g' | pdftk $PDF update_info - output clean-$PDF

### strip metadata from images ImageMagick
mogrify -strip *.jpg

### resize image with ImageMagick
for f in `ls -1 *.jpg`; do convert $f -resize 32%\! tmp.jpg && mv tmp.jpg $f; done

### for a js fs
echo -n "var images = ["; for f in `ls -1`; do echo -n \'$f\', ; done; echo "]"

# rename a bunch of files
for f in `ls -1`; do mv $f file$RANDOM; done


# strip chars from filenames
for f in *; do mv "$f" "$(sed 's/[^0-9A-Za-z_.]/_/g' <<< "$f")"; done