Archive for February, 2008

Batch Resize Images with ImageMagick

Batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick)


find . -maxdepth 1 -name *.jpg -print -exec convert "{}" -resize 80x60 "thumbs/{}" \;

Cpuinfo

Linux command to show information about the CPU


cat /proc/cpuinfo

# Result (example)
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 75
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 3600+
stepping        : 2
cpu MHz         : 2159.980
cache size      : 256 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy ts fid vid ttp tm stc
bogomips        : 4322.80
clflush size    : 64

processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 75
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 3600+
stepping        : 2
cpu MHz         : 2159.980
cache size      : 256 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy ts fid vid ttp tm stc
bogomips        : 4319.37
clflush size    : 64

tree Command

Show files and directories in a tree


tree

Seach for a String in a Folder using grep

Search string “test_text” at directory ‘/var/log’ and below


grep test_text -R /var/log/*

Remove Empty Lines and Comments

Remove comments and blank lines from example.pl


sed '/ *#/d; /^$/d' example.pl

See Mounted File Systems

Shows all mounted file systems in Linux


cat /proc/mounts

Commit All Changes in Git

Telling Git when you’ve added, deleted and renamed files gets tedious. Use this command and Git will look at the files in the current directory and work everything out for itself. The -z and -0 options prevent ill side-effects from filenames containing strange characters.


git-ls-files -d -m -o -z | xargs -0 git-update-index --add --remove

Original Article

Graphical representation of sub-directories

This command shows a graphical representation of the current sub-directories.


ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'mand

Original Article

Remove Empty Lines

Remove empty lines from a file using sed


sed '/^$/d' file.txt

Original Article

List all Installed RPMs by Size

Show space used by rpm packages installed sorted by size (fedora, redhat and like)


rpm -q -a --qf "%10{SIZE}\t%{NAME}\n" | sort -k1,1n