- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: File comparions - Directory levels
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2010 09:14 AM
тАО12-16-2010 09:14 AM
File comparions - Directory levels
tst path # tst files
Note:
This is a delimater "|" dat file.
These directories are having many files , and these file names and layouts are same in production to testing.
I need to check if the prd directory files and tst directories files are same or not( line by line check) . If same then i should get message saying that : Files are matching and also with file names : sizes"
If not matching..those files needs to redirected to the other directory : with the diff report of the lines not matching.
KIndly please help me desinging the script in unix/shell/perl
Thanks for your time!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2010 09:37 AM
тАО12-16-2010 09:37 AM
Re: File comparions - Directory levels
Have a llok at 'diff' and 'dircmp'. See their manpages for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2010 10:16 AM
тАО12-16-2010 10:16 AM
Re: File comparions - Directory levels
I just had try with this,, but not working. PLease can you modify this code to work correctly
prd=/ahome/prkkl/test
tst=/ahome/prkkl/test1
diff=/ahome/prkkl
cd $prd
for a in `ls`; do
if [ ! -f "../$tst/$a" ]; then
continue
fi
diff $a ../$tst/$a > /dev/null
if [[ "$?" == "1" ]]; then
cp $a ../$diff
else
echo "Files are matching"
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2010 10:57 AM
тАО12-16-2010 10:57 AM
Re: File comparions - Directory levels
First, what is "not working" for you.
( By the way, you use 'diff' as the variable name whereas it is the name of a command. This is poor form. )
Second, did you try simply using diff() to compare two directories? Consider this test case:
# ls dir1
f1
# ls dir2
f1 f2
# cat ./dir1/f1
reddykumar
# cat ./dir2/f1
ReDdYkUmAr
...Now:
# diff dir1 dir2
diff dir1/f1 dir2/f1
1c1
< reddykumar
---
> ReDdYkUmAr
Only in dir2: f2
...or if all you want is a message based on the the return code:
# diff dir1 dir2 > /dev/null && echo "SAME" || echo "DIFFERENT"
DIFFERENT
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-16-2010 06:23 PM
тАО12-16-2010 06:23 PM
Re: File comparions - Directory levels
prd=/ahome/prkkl/test
tst=/ahome/prkkl/test1
cd $prd
for file in *
do
if [ ! -f $tst/$file ];then
echo "Missing file copied: $file"
cp -p $file $tst/
fi
done