[...]
if I understand correctly, awk reads the two files and automagically merged records itself ? It means that there is no need to store values from file1 to compare them to file2 ? Beautifull...
[...]
It uses an associative array (a hash), so it guarantees the uniqueness
of the key ($NF in this case) and the value is alway the last one it sees
(the one in file2). It will associate to every key ($NF) the entire record ($0) and it will update the value when it sees the same key.
Quote:
Two things I don't get: the use of the underscore (while i guess it stands for "all read records" ?), and why is END not at the end ?
Well, this is kinda style of writing,
it you want the code more readable,
you could use this instead (and this is compatible even with the old plain Solaris awk):
Quote:
About the sort command wouldn't it fail on the ';' ?
I think the sort command will cast it correctly. Do you have an example where the input like this is not sorted correctly?
Quote:
Do you know how to specify 'last field' of line with sort ?
Or is something like :
| awk '{ printf substr($NF, 1, length($NF)-1);$NF = "";printf " %s\n",$0 }' | sort -n | awk '{ printf "%s%s;\n",$0,$1 }' | awk '{$1="";sub(/^ +/, "");printf "%s\n",$0}'
preferable ?
Why? Isn't the last field position fixed?
In that case I would go with:
Or (if you really want to get rid of the ';' while sorting):
I have a log file which is continuously added to, called log.file. I'd like to
monitor this file, and when certain lines are found, update some totals in
another file. I've played around with tail -f, grep, and awk, but can't seem
to hit the right note, so to speak.
The lines I'm... (0 Replies)
Hi,
I have two text files containing records in following format:
file1 format is:
name1 age1 nickname1 path1
name2 age2 nickname2 path2
file 1 example is:
abcd 13 abcd.13 /home/temp/abcd.13
efgh 15 efgh.15 /home/temp/new/efgh.15 (4 Replies)
Can someone help me again, I think with awk? I have a file with 4 columns (pipe-delimited):
I just want to convert the last field so that e1 is now 'message 1', e2 is 'message 2', e0 is 'message 3', etc. I don't want to change any other columns because the e0-e10 code may appear as part of a... (4 Replies)
I have an extremely large csv file that I need to search the second field, and upon matches update the last field...
I can pull the line with awk.. but apparently you cant use awk to directly update the file? So im curious if I can use sed to do this... The good news is the field I want to... (5 Replies)
I have a file ("modtest") in which I want to update the last date/time block in the lines beginning with a period. Here is a sample:
.ROMULT 10150908EDT 10270908EDT 10010908EDT RANGE
RAWV2 1.00
.ROMULT 10150908EDT 10270908EDT 10010908EDT FGROUP
CHOWANRV 1.00
.RRIMULT 10150908EDT... (10 Replies)
I have another question I am stuck at :wall:
I have a text file with two columns, like so...
2 0.0627279
3 0.0794451
4 0.108705
5 0.137739
6 0.190394
7 0.217407
8 0.241764
9 0.344458
10 0.460762
I'd like to go through the file line by line until the value in the second column... (3 Replies)
I can not seem to figure out how to update the attached match.txt column 2 using update.txt. However, only the text before the period in updat.txt appears in match.txt.
For example, in update.txt NM_001613.2 matches NM_001613 in match.txt, so is it possible to update the record in match.txt to... (8 Replies)
Hi,
I have a file(testfile.txt) that contains list of variables as shown below. T
$$FirstName=James
$$LastName=Fox
$$Dateofbirth=1980-02-04
……and so on there are 50 different variables.
I am writing a script(script1.sh) that will update the above three variable one by one with the values... (6 Replies)
hi,
i have an csv(which is a month's log file containing userid and log in date ) file which has to be appended to another file say master.log.I need to compare the next month's log data to master.log file .In case, there is new log date for userid it has to get updated in master.log file or i... (2 Replies)