![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Comparing two files | guptan | Shell Programming and Scripting | 5 | 08-04-2008 05:02 AM |
| Comparing two files | ragavhere | Shell Programming and Scripting | 31 | 06-12-2008 01:12 AM |
| Finding files with names that have a real number greater then difined. | harmonwood | Shell Programming and Scripting | 2 | 11-09-2007 06:28 AM |
| Comparing 2 files | hdixon | UNIX for Dummies Questions & Answers | 2 | 08-01-2007 09:24 AM |
| comparing two files | marwan | UNIX for Dummies Questions & Answers | 6 | 06-10-2007 11:39 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
comparing shadow files with real files
Hi
I need to compare shadow file sizes with their real file counterparts. If the shadow file size differs form the realfile size then it must send a mail. My problem is that our system has over 1600 shadowfiles in different directories, with different names. the only consistancy is the .sh file ext for shadowfiles. Any easy way of doing this ? Thanx Terry |
| Forum Sponsor | ||
|
|
|
|||
|
Are you sure the .sh files you found are not called .sh because they are shell scripts?
UNIX does not associate what a file is by the file extension like windows does. You can get the "flavor" of a file with the file command Code:
file myscript.sh |
|
|||
|
Code:
#/bin/ksh
# get the base real files
find /path/to/realfiles -name '*' -type f | \
while read file
do
wc -c "$file" | read size dummy
echo "`basename $file` $size"
done > realfiles
# get all the shadow files
find / -type ! -name '/path/to/realfiles/*' |\
while read file
do
wc -c "$file" | read size dummy
echo "`basename $file` $size $file"
done > shadowfiles
# create a file badfiles that is a list of all the failures
awk '{
FILENAME=="realfiles" {
key[$1 $2]++
}
FILENAME=="shadowfiles" {
if( !key[$1 $2]) { print $3 }
}
}' realfiles shadowfiles > badfiles
# send email
cat badfiles | /usr/bin/mailx -s 'bad shadow files' somebody@someplace.com
|