You are here: Foswiki>ALE Web>ExcerciseNumberOne (11 October 2002, AndrewGrimmke)Edit Attach
Bash Problem Solving - Excercise No. 1

Create a command to search your home directory for jpegs, gifs, pngs, tiffs (and any other graphic file format you can think of) and list any files newer that two days old and larger than 2 megs, and also owned by the current user.

Thanks again to David Jackson. Feel free to contribute.

-- AndrewGrimmke - 17 Sep 2002

I used the 'find' command to accomplish this:

find . -name \*.jpg -user $USER -mmin -2880 -size +2000k -o -name \*.gif -user $USER -mmin -2880 -size +2000k -o -name \*.png -user $USER -mmin -2880 -size +2000k -o -name \*.tif -user $USER -mmin -2880 -size +2000k

I'm thinking there must be a shorter version -- what with all the repeated mmin, user, and size options. The only other way I could think of was to write it into a shell script with a 'while'. Other ideas?

-- MeganGolding - 21 Sep 2002

Hi Megan.

Find seems to definitely be the right command here. I think you could save a good number of keystrokes with brackets, like so:

find ~/. -name "*.{jpg,gif,png,tif}" -size +2048 -user $USER -ctime -mtime 2

This is David Jackson's answer and it seems like the best way to me.

Here is ExcerciseNumberTwo.

Check Back. smile

-- AndrewGrimmke - 24 Sep 2002
Topic revision: r4 - 11 October 2002, AndrewGrimmke
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback