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.htmlhttp://www.thegeekstuff.com/2009/07/linux-ls-command-examples/http://www.cyberciti.biz/faq/linux-list-just-directories-or-directory-names/

Advertisements

About Michal Zuber

Biker and rollerblader. Owner and developer at http://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/
This entry was posted in cli and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s