Sort ip address list

“hosts” = file containing hosts.

cat hosts | sort -n -t. -k 1,1 -k 2,2 -k 3,3 -k 4,4

This sorts all octets as well.


Script to recode mp4 files to avi Divx

Using avidemux to recode mp4 files to Divx .avi. Script converts all files in current dir. Uses avidemux.

ls *.mp4 | sort > $VAR # Collect the files in the current directory
cat $VAR | while read line; do  # Loop read the filenames from the file
  INPUT=$(echo ${line}) # Grab the nxt new filename
  OUTPUT=${INPUT%.*4} # Remove shortest match of characters between the '. ' and the '4' at end of string
  OUTPUT+=".avi" # Append new extension
  avidemux --force-alt-h264 --output-format AVI --video-codec Xvid --audio-codec mp3 --load "$INPUT" --save "$OUTPUT" --quit 
rm $VAR # Remove the text file with the file names