- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script that compares two files and removes duplica...
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
тАО04-28-2011 09:52 AM
тАО04-28-2011 09:52 AM
I have two files that list the disks on my server. The first file lists the disks that are part of vg00 and the second file lists all pvs onr the server. I am looking for a way to create a third file that shows only the disks that are not part of vg00.
Example:
file1.txt disks that are part of vg00
c0t2d0s2
c1t2d0s2
file2.txt all disks on server
c0t2d0
c0t2d0s1
c0t2d0s2
c1t2d0
c1t2d0s1
c1t2d0s3
c8t14d5
c8t14d6
c8t14d7
c8t15d0
...
file3.txt should look like this
c8t14d5
c8t14d6
c8t14d7
c8t15d0
file3.txt should not have any disks that are part of vg00.
Thanks for any input you can provide.
Tommy P.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2011 10:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-28-2011 10:56 AM
тАО04-28-2011 10:56 AM
Re: script that compares two files and removes duplicates.
Have a look at 'comm(1)'.
Regards!
...JRF...
- Tags:
- comm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-29-2011 09:06 AM
тАО04-29-2011 09:06 AM
Re: script that compares two files and removes duplicates.
## (sed < /tmp/f1 >/tmp/f1s \
-e 's/s.*//'
fgrep < /tmp/f2 >/tmp/f3 \
-v -f /tmp/f1s
cat /tmp/f3
)
c8t14d5
c8t14d6
c8t14d7
c8t15d0
or, if you don't want a temp file
## ( sed < /tmp/f1 \
-e 's/s.*//' \
|while read D
do e="$e -e $D"
done
grep < /tmp/f2 >/tmp/f3 \
-v $e
cat /tmp/f3
)
c8t14d5
c8t14d6
c8t14d7
c8t15d0
Note the second scriptlet above is not portable to Linux,
because of child shell variable issues.
Portable scriptlet:
## ( sed < /tmp/f1 \
-e 's/s.*//' \
|(while read D
do e="$e -e $D"
done
echo " $e"
) \
|(read e
grep < /tmp/f2 >/tmp/f3 \
-v $e
)
cat /tmp/f3
)
bv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-10-2011 09:47 AM
тАО05-10-2011 09:47 AM