The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Comparing two files ragavhere Shell Programming and Scripting 32 12-04-2008 01:24 PM
Comparing two files guptan Shell Programming and Scripting 5 08-04-2008 08:02 AM
Finding files with names that have a real number greater then difined. harmonwood Shell Programming and Scripting 2 11-09-2007 10:28 AM
Comparing 2 files hdixon UNIX for Dummies Questions & Answers 2 08-01-2007 12:24 PM
comparing two files marwan UNIX for Dummies Questions & Answers 6 06-11-2007 02:39 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-08-2007
terrym terrym is offline
Registered User
  
 

Join Date: Feb 2007
Location: Centurion, SOuth Africa
Posts: 6
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
  #2 (permalink)  
Old 02-08-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,715
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
will return something like "Bourne Shell script" if it is a Bourne shell script, for example.
  #3 (permalink)  
Old 02-08-2007
terrym terrym is offline
Registered User
  
 

Join Date: Feb 2007
Location: Centurion, SOuth Africa
Posts: 6
the .sh are application shadow files, this has been confirmed.
  #4 (permalink)  
Old 02-08-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,715
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
Start with this code. Before you try mailing anything check both shadowfiles and realfiles and badfiles for content.
  #5 (permalink)  
Old 02-09-2007
terrym terrym is offline
Registered User
  
 

Join Date: Feb 2007
Location: Centurion, SOuth Africa
Posts: 6
Thumbs up

Thank you so much. Appreciate the help
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:34 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0