- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell script dont work with awk.
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-01-2009 05:47 AM
тАО12-01-2009 05:47 AM
Re: Shell script dont work with awk.
Too specific. zip would be ok, but a plain .TXT file with indication of the inputs, and a example of the desired output MATCHING that input would work best for me, and maybe for others.
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2009 05:59 AM
тАО12-01-2009 05:59 AM
Re: Shell script dont work with awk.
10.45.6.8
192.56.7.9
....
....
....
The file to compare with is a output file from a DB, same deal
10.4.5.7
...
...
...
The script reads those two files into arrays.
And a while loop just reads every line from one file and trys to find a match in the other file. If a match is found it directs the result to the file Identical.txt. That are later used to exclude all identical IP-addresses so I get a file with IP-addresses that should not be in the DB.
Dont know how to explain it more :-(
See attached ZIP file!
Best regards Stefan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2009 09:25 AM
тАО12-01-2009 09:25 AM
Re: Shell script dont work with awk.
the term we are trying to explain is the difference between 'match' and 'equal'.
The line
awk 'NR==FNR {ip[$1]=$1} NR>FNR {if(ip[$1]) print "double ip",$1}' seedFile.txt InPut.txt
will NOT do a match, but output equal col1 values.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2009 06:04 AM
тАО12-02-2009 06:04 AM
SolutionThe shell script you finally provided is different from what you originally posted.
The awk line has a single '>', and therefor only the output from the final execution will remain.
The match function, will return 0 if there is no match right. And non-0 if it matched ANYWHERE on the line.
You knew that right?
Here is an other example of a fine match which may surprise you:
$ awk 'BEGIN { print match("23.91.181.12","1.1.1.1")}'
5
Anyway, why bother with all this stuff if there is a standard tool ready to do all this??
As I indicated before, just use grep -f
grep -f seedFile.txt InPut.txt > IdenticalIp.txt
grep -v -f seedFile.txt InPut.txt > toBeExcluded.txt
Of course you still have to worry about the . being a wildcard, also for grep.
And you possibly need to worry for the match not being anchored. For example, if someone added a comment :
w.x.y.z # Use to 1.2.3.4
Depending on the grep available you may want use:
-F, --fixed-strings PATTERN is a set of newline-separated strings
-x, --line-regexp force PATTERN to match only whole lines
-w, --word-regexp force PATTERN to match only whole words
Enjoy!
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2009 10:37 AM
тАО12-02-2009 10:37 AM
Re: Shell script dont work with awk.
Will go for that soultion.
And no! I did not know that awk match worked like that. Thank you for clarifying that to me :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-02-2009 10:52 AM
тАО12-02-2009 10:52 AM
Re: Shell script dont work with awk.
- « Previous
-
- 1
- 2
- Next »