I need to add new ID to the file with old ID (column 7), I collected old ID / new ID pairs in a lookup file and I am trying to use awk to do the job, but something is not clicking.
My input file
I need to get this
My lookup file
My awk code (with all the debug I put in it)
Run results:
I'd appreciate it very much if someone can point me in the right direction, thanks in advance.
Last edited by migurus; 09-22-2015 at 04:48 PM..
Reason: typo
You need field specifiers of both space and pipe symbol, otherwise your search is looking for a number preceeded by a space. You want only digits in the search.
With newer awk specify the field separator characters with -F
like awk -F '[ |]'
Thanks.
I changed my FS / OFS assignment to be
But it did not change anything.
Just a note: I just want to point out that I initiate old_key to 0 (zero) in BEGIN section, hoping it will be integer.
---------- Post updated at 01:11 PM ---------- Previous update was at 01:01 PM ----------
Thanks, Jim, your suspecting spaces were right (I did too, thought my old_key is integer and will deal with spaces properly)
My awk does not support "[ |]" for SEP, when I tried your suggestion my $7 field became 0, that is why it did not work
I removed blanks from 7th column in the input and it worked.
Now, question, what is the best way to tell awk to disregard those spaces?
Hi,
I'm new to scripting and unable to find out a way to perform the below task. Request help in finding out a way to accomplish this.
File one consists of some numbers/string which i need to lookup against file 2 and fetch the best match results in output. If best match is not present in... (3 Replies)
I am trying to update the below awk, kindly provided by @RavinderSingh13, to update each line of file1 with either Low or No Low based on matching $2 of file1 to a range in $2 and $3 of file2. If the $2 value in file1 matches the range in file2 then that line is Low, otherwise it is No Low in the... (3 Replies)
Hello everyone,
I have been struggling with the following situation, I think I am doing something wrong, can anyone help?
I have 2 comma separated files, the first is a look-up table that will supply the phone number based on the customer id, the second is a file containing customers and their... (4 Replies)
I'm running a NIS on an network of Ubuntu 8.04 linux systems. I'm seeing a weird problem where the 'id' command is not returning all the groups I am a member of. For example:
alex@client $ id -Gn
localgroupA localgroupB nisgroup1 nisgroup2 nisgroup4
alex@client $ id -Gn alex
nisgroup1... (0 Replies)
I'm at wits end with this issue and my troubleshooting leads me to believe it is a problem with the file formatting of the array referenced by my script:
awk -F, '{if (NR==FNR) {a=$4","$3","$2}\
else {print a "," $0}}' WBTSassignments1.txt RNCalarms.tmp
On the WBTSassignments1.txt file... (2 Replies)
Hi
I have one properties file containing as
$INSTALL_BASEPATH/mssages/commonmessages_default.properties
$INSTALL_BASEPATH/resource/configurationBundle.properties
and $INSTALL_BASEPATH is set in .bash_profile
but from shell script when I read this file
and use in copy statement then it... (7 Replies)
I want to lookup filea with fileb,filec and filed.
If entry in filea exist in fileb and filec mark Y and then if entry in filea exist in filed mark as Y.
Final output should have all the entries from filea.
This prints only matching entries from file a in fileb i want all entries from... (9 Replies)
Write a quick shell snippet to find all of the IPV4 IP addresses
in any and all of the files under /var/lib/output/*, ignoring
whatever else may be in those files. Perform a reverse lookup on
each, and format the output neatly, like "IP=192.168.0.1,
... (0 Replies)
Hi All,
I have two files file1 and file2(lookup file).I need to map more than one keyfields of file1 with file2.how can we achieve it using awk.
file1(max 2.2 million records)
--------------------------
680720|680721|077
680720|680721|978
680721|680722|090
file2(no idea about the... (1 Reply)
I'm trying to create a reverse lookup file. Below are the error messages I get in the messages file, when I start named. Below the error messages is a copy of the reverse lookup file I'm trying to use. I'm using Bind version 8.1.2. Would someone recommend the correct values and if you see any... (2 Replies)