Computing.Net > Forums > Programming > Unix script for generating a report

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Unix script for generating a report

Reply to Message Icon

Original Message
Name: new_bee
Date: February 8, 2007 at 12:17:07 Pacific
Subject: Unix script for generating a report
OS: Solaris 9
CPU/Ram: Sparc sun4u
Model/Manufacturer: Sun-Fire 3800
Comment:

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


Report Offensive Message For Removal


Response Number 1
Name: nails
Date: February 9, 2007 at 16:14:34 Pacific
Reply: (edit)

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 Offensive Follow Up For Removal

Response Number 2
Name: Guy
Date: February 9, 2007 at 18:28:05 Pacific
Reply: (edit)

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 Offensive Follow Up For Removal

Response Number 3
Name: new_bee
Date: March 6, 2007 at 13:24:50 Pacific
Reply: (edit)

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 Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software