16.2.14

Linux special case listing options, tricks

To list only files beginning with the specified character:

mike@jarvis:/media/sdb1/jpg$ ls -1 [A]*.jpg
A-AM11-GGD_icon01_s_1.jpg
A-AM11-GGD_icon01_s.jpg
A-AM13-GGD_icon02_s_1.jpg
A-AM13-GGD_icon02_s.jpg

mike@jarvis:/media/sdb1/jpg$ ls -1 [a]*.jpg
a001_1.jpg
a001.jpg
a002_1.jpg
a002.jpg
a003_1.jpg
a003.jpg
a004_1.jpg
a004.jpg
a005_1.jpg
a005.jpg
Finding PNG images greater than 800 pixels:
for f in *.png;do if [ `file $f | cut -f5 -d\ ` -gt 800 ] ; then echo $f;fi;done
Finding JPG images greater than 800 pixels (requires installed imagemagick, to have identify command):
for f in *.jpg;do if [ `identify "$f" | cut -f3 -d ' ' | cut -f1 -d x` -gt 800 ] ; then echo "$f";fi;done

Resources that can also help:
http://www.codecoffee.com/tipsforlinux/articles/26-1.html http://www.thegeekstuff.com/2009/07/linux-ls-command-examples/ http://www.cyberciti.biz/faq/linux-list-just-directories-or-directory-names/

No comments:

Post a Comment