- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- question with join command..
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
тАО12-18-2006 01:49 AM
тАО12-18-2006 01:49 AM
file1(pattern):
100018
100090
100143
100198
100346
100708
100961
100989
101037
101206
101543
101931
102306
102371
102504
102605
102640
102823
103025
103390
file2:
320346|006|12|11
901546|007|1|11
220054|007|12|11
100018|007|1|11
901411|007|12|11
380094|007|12|11
320046|006|12|11
901946|007|1|11
220854|007|12|11
310776|007|1|11
901611|007|12|11
380194|007|12|11
result should be:
100018
so basicly join 2 files and if record is listed in pattern(file1) do not print that record..
this is what I tryed so far:
join -t'|' -a1 file1 file2
but results are not OK..
then I also tryed this:
join -1 1 -2 1 -t'|' -a 1 file1 file2
still not OK??
can someone correct my misstake..
Thanks a lot..I am still beginner here but I try hard to make something..
cheers,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 01:56 AM
тАО12-18-2006 01:56 AM
SolutionFrom your example, it's not clear if you DO or DO NOT wish to print matching records in file2.
If you DO want matching records printed:
$ grep -F -f file1 file2
100018|007|1|11
If you wish to EXCLUDE matches in file2:
$ grep -F -v -f file1 file2
320346|006|12|11
901546|007|1|11
220054|007|12|11
901411|007|12|11
380094|007|12|11
320046|006|12|11
901946|007|1|11
220854|007|12|11
310776|007|1|11
901611|007|12|11
380194|007|12|11
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 02:03 AM
тАО12-18-2006 02:03 AM
Re: question with join command..
If you truly want to use 'join' you need to sort your input files. See the manpages for 'join' for more information.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 02:07 AM
тАО12-18-2006 02:07 AM
Re: question with join command..
It works with command:
grep -F -f file1 file2
cool..but still I wanted to practice join command becouse I find it cool..
Thanks a lot
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-18-2006 02:41 AM
тАО12-18-2006 02:41 AM
Re: question with join command..
>file1 and file2 must be sorted in increasing collating sequence (see >Environment Variables below) on the fields on which they are to be joined; >normally the first in each line.
So sort file1 and file2 before using the join(1) command on them, i.e.
# sort -k1,1 file1 > file1.out
# sort -t'|' -k1,1 file2 > file2.out
# join -1 1 -2 1 -t'|' -o 1.1 file1.out file2.out
~cheers