- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- file the same file name
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
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
тАО07-25-2005 03:28 PM
тАО07-25-2005 03:28 PM
/tmp/dir1
file1
file2
file3
file4
file5
/tmp/dir2
file5
file6
file7
file8
file9
so I would like to find out "file5" as the file are persented at both directories.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 03:44 PM
тАО07-25-2005 03:44 PM
Re: file the same file name
do
if [ -a /tmp/dir2/$file ]
then
echo $file
fi
done
- Biswajit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 04:43 PM
тАО07-25-2005 04:43 PM
Re: file the same file name
ls -1 /tmp/dir2 > list2
grep -f list1 list2 > common_files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 05:59 PM
тАО07-25-2005 05:59 PM
SolutionVibhor solution looks much easy to use.
Just to put it in script e.g. "script1":
----------------------------
#!/usr/bin/ksh
ls -1 /tmp/dir1 > list1
ls -1 /tmp/dir2 > list2
grep -f list1 list2
-----------------------------
# chmod +x script1
# ./script1 dir1 dir2
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 06:00 PM
тАО07-25-2005 06:00 PM
Re: file the same file name
----------------------------
#!/usr/bin/ksh
ls -1 $1 > list1
ls -1 $2 > list2
grep -f list1 list2
-----------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 06:08 PM
тАО07-25-2005 06:08 PM
Re: file the same file name
You can also use dircmp(1)
it will give you 2 lists:
1: a list of files that only exist in either dir1 or dir2
2: a list of files which exist in both dirs
Also it compares the files and will tell you if the files are different or the same
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 08:16 PM
тАО07-25-2005 08:16 PM
Re: file the same file name
1) diff -s /tmp/dir1 /tmp/dir2 | grep 'identical'
2) dircmp /tmp/test1 /tmp/test2 | grep 'same'
hth.