Unix script for generating a report

Sun-Fire 3800
February 8, 2007 at 12:17:07
Specs: Solaris 9, Sparc sun4u

Hi,

I am very new of writing shell script. How can I write a shell script to generate a report on the directory contents? For example, I have a lot of jpg files under a directory and some sub-directories,for example /tmp/files/file1/1.jpg, how can I print a report for all the .jpg files that I saved? Users will keep adding new jpg to this directory, for example /tmp directory, and I want to use that report to check if there is any duplicate jpg pics.

Please assist,
new_bee


See More: Unix script for generating a report

Report •


#1
February 9, 2007 at 16:14:34

Take a look at the first tip in this column, Finding Duplicate Files:

http://www.unixreview.com/documents...

It uses the checksum of files sorted by size. Since you're interested in only jpg files, you'd probably want to change the find command in the script to look like this:

find . -type f -name "*.jpg" -print

Let me know if you have any questions.


Report •

#2
February 9, 2007 at 18:28:05

I'd like to add that there is a Linux/BSD package called 'fdupes' (roughly).

Does the checksum thing.

Works, I use it.

Presumably could be built and installed on Solaris.

Guy



Report •

#3
March 6, 2007 at 13:24:50

Thanks for the prompt responses! I was out sick because of the unstable weather.

Hi nails,

Thanks for the link, I could try the script right away. But as I explain, I am very new to Solaris platform and shell script, please forgive me if my following questions are too dump.

1/ Where should I place the duplicate script to? For example, if I want to compare the jpg files in 10 different directories, dir1, dir2, dir3, dir4..., dir10? Then I place it to every directory? If it is true, how could I compare the .jpg files among these 10 directories?

2/ How could I run and test the script?

3/ Where does the output send to?

4/ If I want to add this script to the cron job and run it once a week, how?

5/ And if I want to send the result to my email address, how? Write another script?

Thanks again,
new_bee


Report •

Related Solutions


Ask Question