- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Script help needed
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
тАО07-17-2007 10:53 AM
тАО07-17-2007 10:53 AM
This is an easy one, but for some reason it escapes me. This is what I need to do...
I have FileA that has a long list of miscellaneous entries
I have FileB that has a partial list of what FileA has in it.
I need to create FileC that has what is in FileA less FileB. How is the best way to pull this off? Thanks again.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2007 11:10 AM
- Tags:
- comm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2007 11:13 AM
тАО07-17-2007 11:13 AM
Re: Script help needed
Regds,
Kaps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2007 12:01 PM
тАО07-17-2007 12:01 PM
Re: Script help needed
...and if for whatever reason your files are not sorted or cannot be sorted, use:
# cat ./filter
#!/usr/bin/perl
use strict;
use warnings;
my $fileA = shift or die "Usage: FileA FileA\n";
my $fileB = shift or die "Usage: FileA FileB\n";
my %line;
my @list;
open( FH, "<", $fileB ) or die "Can't open $fileB: $!\n";
while (
$line{$_}++;
}
close FH;
open( FH, "<", $fileA ) or die "Can't open $fileA: $!\n";
while (
push @list, $_ unless exists $line{$_};
}
print for @list;
1;
...run as:
# ./filter fileA fileB
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2007 01:32 PM
тАО07-17-2007 01:32 PM
Re: Script help needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-17-2007 03:14 PM
тАО07-17-2007 03:14 PM
Re: Script help needed
No need to use cat:
$ grep -vf FileB FileA > FileC
You'll have bad performance if the number of lines in FileB and FileA are very large.
A caution about grep, if FileB has lines are substrings of other lines in FileA, you'll miss them. You can fix this with grep -x.