Computing.Net > Forums > Unix > script to match values

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

script to match values

Reply to Message Icon

Name: myguess21
Date: February 25, 2008 at 09:33:07 Pacific
OS: Sun solaris
CPU/Ram: na
Product: hp
Comment:

Hi, I need a unix script which can check the values from file1 into file2 and if they do not match then print that line from file1.

file1

check1 name1 lastname1 email
check2 name1 lastname1 email
check30 name1 lastname1 email
check3 name1 lastname1 email

File2
check1 name1 lastname1 email
check1 name1 lastname1 email
check2 name1 lastname1 email
check3 name1 lastname1 email
check5 name1 lastname1 email

Output:
check30 name1 lastname1 email

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: James Boothe
Date: February 25, 2008 at 12:23:37 Pacific
Reply:

This script matches on word1 only, but could just as easily match on entire line.

awk 'BEGIN{
while ((getline < "file2") > 0)
list[$1] = 1}
!list[$1] {print}' file1


0

Response Number 2
Name: COE
Date: March 11, 2008 at 02:16:11 Pacific
Reply:

good morning all

i have a problem which is:

I have two file

file1

12 CD 1234
54 RC 6543
45 CD 4567
65 RC 2345

file2

45 CD 4567
54 RC 6543

I want to take every line in file1 and search in file2 if the line does not exsist
print it in a new file

the output should be like this

file3

12 CD 1234
65 RC 2345

please Help!


0

Response Number 3
Name: COE
Date: March 11, 2008 at 02:22:21 Pacific
Reply:

I want the solution with nawk if possible


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: script to match values

shell script to get value of field www.computing.net/answers/unix/shell-script-to-get-value-of-field/6716.html

Script to change values linebyline www.computing.net/answers/unix/script-to-change-values-linebyline/8308.html

converting bash script to csh script www.computing.net/answers/unix/converting-bash-script-to-csh-script/3588.html