- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Distinct lines from FileA
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
06-14-2007 02:29 AM
06-14-2007 02:29 AM
May be something like
lines=`ec -l fileA`;
i=1
while [ $i -le $lines ]
do
if line$i NOTfound in fileB then >> NOTPRESENT.txt
i=i+1
done
Please suggest!!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 02:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 02:50 AM
06-14-2007 02:50 AM
Re: Distinct lines from FileA
Also, please advice how can i get the output printed with line numbers?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 03:11 AM
06-14-2007 03:11 AM
Re: Distinct lines from FileA
# comm -23 fileA fileB | nl -nln -s' '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 03:19 AM
06-14-2007 03:19 AM
Re: Distinct lines from FileA
F1=A
F1S=A.sorted
F2=B
F2S=B.sorted
F1U=A.unique
sort ${F1} > ${F1S}
sort ${F2} > ${F2S}
comm -23 ${F1S} ${F2S} > ${F1U}
grep -F -n -f ${F1U} ${F1}
rm -f ${F1S} ${F2S} ${F1U}
exit 0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 03:19 AM
06-14-2007 03:19 AM
Re: Distinct lines from FileA
do
j=$serv_cnt
echo "===[ Directory List for Server: $serv_cnt ]==="
ssh $serv_cnt "find /mfgdata/ -type d -exec ls -ld {} \; 2>/dev/null "
done >> $j.mfgdata-ux-dir.ls
How can I dynamically generated output file with differnt names???
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 03:25 AM
06-14-2007 03:25 AM
Re: Distinct lines from FileA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 04:11 AM
06-14-2007 04:11 AM
Re: Distinct lines from FileA
I ran below command:
comm -23 data-ux-9th.lst data-lx-9th.lst | nl -nln -s' ' > not-in-lx-data.lst
found that output file still has below entries:
data/amfp2p/log/api/IPCSH
data/amfp2p/log/scm
data/amfp2p/log/audit
data/amfp2p/log/ecgei
Though, these were present in both files. Do i need to sort files beforehand. Please suggest how can i run comm command?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 04:23 AM
06-14-2007 04:23 AM
Re: Distinct lines from FileA
sort ${F1} > ${F1S}
sort ${F2} > ${F2S}
Also, in this scenario, 'nl' is going to number the lines of output piped from the 'comm' command--not the position of lines unique to fileA. I suggest using the script I supplied.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 05:03 AM
06-14-2007 05:03 AM
Re: Distinct lines from FileA
Try it?
Hein
---- compare_file_lines.pl ----------
#
# Open first file and remember all lines with their line numbers in array f1
#
$name = shift @ARGV or die "Must provide first filename";
open FILE, "<$name" or die "Could not read file $name";
while (
chomp;
next if /^$/; # skip blanks
next if /^\s+#/; # skip comments
$f1{$_}=$.;
}
close FILE; # reset line number
#
# open and loop through second file.
# delete each corresponding element from the array
# Report if missing (could be duplicate in second file)
#
$name = shift @ARGV or die "Must provide second filename";
open FILE, "<$name" or die "Could not read file $name";
while (
chomp;
next if /^$/; # skip blanks
next if /^\s+#/; # skip comments
next if delete $f1{$_};
print "2:$. not in 1:$_\n";
}
#
# All lines remaining in array must not have been in second file
#
foreach (sort {$f1{$a} <=> $f1{$b}} keys %f1) {
print "1:$f1{$_} not in 2:$_\n";
}
-------------------------
# perl compare_file_lines.pl left right
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 05:49 AM
06-14-2007 05:49 AM
Re: Distinct lines from FileA
#!/usr/bin/sh
sort fileA > fileA.srtd
sort fileB > fileB.srtd
comm -23 fileA.srtd fileB.srtd | nl -nln -s' '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 07:05 PM
06-14-2007 07:05 PM
Re: Distinct lines from FileA
Line numbers starting from 1? Or starting from the original file1?
Sandman did the first. spex did the latter but his fgrep -n -f will kill you on performance if the number of records is large.
If you really want to do this, you need to number each file with nl and a ID, then sort, then use awk to look for lines only in first file.
Let me know if you are interested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2007 11:19 PM
06-14-2007 11:19 PM