awk script to perform an action similar to vlookup between two csv files in UNIX
Hi,
I am new to awk/unix and am trying to put together an awk script to perform an action similar to vlookup between the two csv files.
Here are the contents of the two files:
File 1:
File 2:
I am trying to do a lookup between the two files based on the date and the parent ID. If the date AND The parent ID are the same, the "ID" (first column from in file 2) needs to be copied to file 1 (as the first column). If they are not the same, then a blank should be copied to file 1.
@Franklin52 and @Chubler_XL thanks for your replies!
File 1 currently does not have a ID column. This ID column has to be inserted. @Franklin52, when I try tried your approach, the outout is exactly file1 without the ID column inserted?
@Chubler_XL, when I try your approach, the output is as follows:
Hi,
I want to compare same column in two files, if values match then display the column or display "NA".
Ex :
File 1 :
123
abc
xyz
pqr
File 2:
122
aab
fdf
pqr
fff
qqq
rrr (1 Reply)
I need to vlookup and check the server not found.
Source file 1
server1
server2
server3
server4
server5_root
server6_silver
server7
server7-test
server7-temp
Source file 2
server1_bronze (6 Replies)
Hi All,
I need to create a script to monitor a dir for new files with ext .err and also it should b a non empty files. and perform a action or command .
We have a new ETL application that runs on a linux server, every times a etl fails it creates a .err file or updates the existing .err... (4 Replies)
Thanks Bartus11 for your help in the following code to compare the two files "t1" and "t2".
awk 'NR==FNR{a=1;next}$2 in a{print $2}' t1 t2
First can anyone explain that what is the purpose of assigning a =1?
Second, the current script is printing out the matched columns between the... (4 Replies)
Hi,
I want to access files from different directories (for example: /home/dir1/file1 , /home/dir2/file2 ...) Like this i have to access these files(file1, file2...). (3 Replies)
hi,
i have a service on unix platform, it will generate traces in a particular folder
i want to check using shell script if traces exist, then perform some action else continue to be in loop.
filename is service.tra
can you please help?
thanks (4 Replies)
I have 2 files. I basically want to search both of them to see if the 1st column ($1) matches and if it matches then check to see if the 2nd column ($2) matches, then execute some code showing the results of the matches.
File 1:
AAA 123
misc blah
BBB 456
CCC 789
File 2:
... (2 Replies)
I have a large CSV files (e.g. 2 million records) and am hoping to do one of two things. I have been trying to use awk and sed but am a newbie and can't figure out how to get it to work. Any help you could offer would be greatly appreciated - I'm stuck trying to remove the colon and wildcards in... (6 Replies)
Hello,
I have a script that monitors files uploaded via ftp. After a successful upload, the file name is written to the pipe.
There is another program that reads this pipe and allows automatically run any program or script ( say test.sh ) to process the newly uploaded file.
cat test.sh... (2 Replies)