- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Compare two files
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
тАО09-21-2009 06:48 AM
тАО09-21-2009 06:48 AM
I have List A and List B. List A contains a list of excludes. How do I extract from ListB all that is not in List A?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 07:00 AM
тАО09-21-2009 07:00 AM
Re: Compare two files
use 'comm' [see the manpages for details].
# comm -23 fileb filea
Regards!
...JRF...
- Tags:
- comm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 07:14 AM
тАО09-21-2009 07:14 AM
Re: Compare two files
/var
/stand
/tmp
Then List B will have something that looks like this:
/abc/def/ghi/jkl/file.ksh
/var/adm/syslog/syslog.log
/tmp/file.txt
/anotherdir/path/file
So I want to output all in FileB except anything with the string in it from FileA. So anything that starts with /var; /stand; or /tmp.
I am trying to find all files of a certain type from all directories BUT the ones in ListA. I have a find that will print out all the files found. Then I was thinking I could somehow grep out all files starting with anything in List A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 07:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 07:27 AM
тАО09-21-2009 07:27 AM
Re: Compare two files
grep -v -w -f listA listB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 08:16 AM
тАО09-21-2009 08:16 AM
Re: Compare two files
> I should explain my situation better.
And I believe I answered what you asked.
http://www.catb.org/~esr/faqs/smart-questions.html
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-21-2009 09:43 AM
тАО09-21-2009 09:43 AM
Re: Compare two files
Apparently in this case that is the behavior you want. In some cases it would not be and the grep command would fail in that case.
Also the grep command would fail in your case as well, if you have "/var" in listA and /usr/opt/common/var/keep" in ListB.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-22-2009 12:37 AM
тАО09-22-2009 12:37 AM
Re: Compare two files
You will need to change FileA so that you anchor the RE:
^/var
^/tmp
^/stand
Then you can use:
grep -v -f FileA FileB