- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Comparing directory trees
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
Forums
Discussions
Discussions
Discussions
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
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-05-2003 03:29 AM
12-05-2003 03:29 AM
I think I need to use ll and comm commands but am stuck because of the way ll lists files in a directory tree. Instead of listing every file in the tree along with it's directory on one line, it lists the files under headings which specify the directory.
This makes the files impossible to compare!
Anyone ever had to sort this kind of problem or got any bright ideas???
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 03:35 AM
12-05-2003 03:35 AM
Re: Comparing directory trees
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 03:37 AM
12-05-2003 03:37 AM
Re: Comparing directory trees
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 03:38 AM
12-05-2003 03:38 AM
Re: Comparing directory trees
I'm not sure whether this would help you, but have you looked at the find command? It will chase down through the directory trees for you, printing out the names of the files as it finds them, or you can ask it to perform a command on each file as it finds them (like ls -l, for example: find /start_dir -exec ll {} \;). Do a man on "find" and take a look at the examples.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 03:39 AM
12-05-2003 03:39 AM
SolutionIf so then something like this may do:
cd dir1
find . | sort > tempfile1
cd dir2
find . | sort > tempfile2
comm -12 tempfile1 tempfile2
rm tempfile1 tempfile2
find will print every file as a relative pathname so you should be able to compare them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 04:00 AM
12-05-2003 04:00 AM
Re: Comparing directory trees
cd /dir1
find . -type f -print |sort > /tmp/dir1
cd /dir2
find . -type f -print |sort > /tmp/dir2
comm -3 /tmp/dir[12]
rm /tmp/dir[12]
Elena.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 04:12 AM
12-05-2003 04:12 AM
Re: Comparing directory trees
try this:
#!/bin/ksh
find /dir1 -type f -exec ls -l '{}' ';' | awk -f t11.awk > files1
find /dir2 -type f -exec ls -l '{}' ';' | awk -f t11.awk > files2
comm -3 files1 files2
# cat t11.awk
BEGIN{FSX=FS;}
{
for (i=1; i<=NF-1; i++)
printf("%s ",$i);
FS="/";
printf("%s\n",$NF);
FS=FSX;
}
END{}
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2003 04:27 AM
12-05-2003 04:27 AM
Re: Comparing directory trees
I would suggest you to try the join command.
First create one file for each directory tree with "find . -print >
Last, "join outfile1 outfile2" which produces an output for each matching line. There is several options for join (for example not matching lines), have a look at the man page.
The difference with join compared to comm is that join worka also when there is not equal numbere of lines in the files and with 1 to many relations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-21-2003 10:34 AM
12-21-2003 10:34 AM
Re: Comparing directory trees
Lived in Northwood Middlesex in Westbury Road. Is that you?
This is Sandro, the itlaian at jamesaltt@yahoo.it, trying to get in contact with you.
If details do not match, ignore this note
Bye
Sandro