Monday, September 14, 2009

Linux Tip/Tricks continue...

Command to search packages with duplicats sort them

rpm -qa --qf "%{name} %{epoch}:%{version} - %{arch}\n" | sort


Creating thumbnails on the fly using ImageMagick

for img in *.jpg; do convert -resize 200 "$img" thumb_"$img";done


Renaming all files in current directory to filename.orig - you should use quotes around $file if your filenames contain spaces

for file in *; do mv $file $file.orig; done


Chop value to two decimal places using 'bc'

printf "%.2f\n" $(echo $'scale=2\n'"1.006"'+.005' | bc)


Finds all files over 20,000KB (roughly 20MB) in size and presents their names and size in a human readable

find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'


OR

find / -type f -size +20M -exec ls -lh {} \;

Find some text in lot of files and then delete those files

grep -rls "PATTERN" . | tr '\n' '\0' | xargs -0 rm

No comments:

Post a Comment