awk to create subdirectory based on match between two files
In the below awk I am trying to mkdir based of an exact match between file2 line starting with R_2019.... and file1 line starting with R_2019. When a match is found there is a folder located at /home/cmccabe/run with the same name as the match where each $2 in file1 is a new subdirectory in that folder. There will always be a match to an R_2019...., but there may be more then one. That is there may be 2 or 3 R-2019.... that have matches but they will always be unique. The awk as is does execute but produces nothing so I tried adding cmd_fmt='mkdir -p "%s/%s" to store each new subdirectory in cmd_fmt. Then added -v cmd_fmt="$cmd_fmt" to the start of the awk to create the matched sub-directory but that did not work as expected. I am using ubuntu 14.04 and added comments. Any line in file1 that has Negative in it can be skipped as well and does not need a sub-directory created. Thank you .
awk
file1
file2
Last edited by cmccabe; 03-18-2019 at 09:15 PM..
Reason: fixed format
Switching file1 and file2 should match the R_2019...], but the sub-directories are going to created in the same directory where file1 and file2 exsist not in the desired i think. Thank you .
Hi,
i have 2 files , the data i need to match is in masterfile and i need to pull out column 3 from master if column 1 and 2 match and output entire row to new file
I have tried with join and awk and i keep getting blank outputs or same file
is there an easier way than what i am... (4 Replies)
I have the below input data in a file and need to get the output as mentioned below. Need to sort the data by size(Asc/des)/by subdirectory
Below is the input which is there in a file:
120 /root/path2/part-00000-d3700305-428d-4b13-8161-42051f4ac5ed-c000.json
532 ... (3 Replies)
I am trying to create a cronjob that will run on startup that will look at a list.txt file to see if there is a later version of a database using database.txt as the source. The matching lines are written to output.
$1 in database.txt will be in list.txt as a partial match. $2 of database.txt... (2 Replies)
I am trying to use awk to match two files that are tab-delimited. When a match is found between file1 $1 and file2 $4, $4 in file2 is updated using the $2 value in file1. If no match is found then the next line is processed. Thank you :).
file1
uc001bwr.3 ADC
uc001bws.3 ADC... (4 Replies)
I am trying to look for $2 of file1 (skipping the header) in $2 of file2 (skipping the header) and if they match and the value in $10 is > 30 and $11 is > 49, then print the line from file1 to a output file. If no match is foung the line is not printed. Both the input and output are tab-delimited.... (3 Replies)
Trying to match $2 in original_targets with $2 of new_targets . If the two numbers match exactly then a match.txt file is outputted using the information in the new_targets in the beginning 4 fields $1, $2, $3, $4 and value of $4 in the original_targets . If there is "No Match" then a no... (2 Replies)
Hello:
I am working parsing a large input file which will be broken down into multiples based on the second field in the file, in this case: STORE.
The idea is to create each file with the corresponding store number, for example: Report_$STORENUM_$DATETIMESTAMP , and obtaining the... (7 Replies)
Howdy Folks,
I have a list that looks like this:
(file2.txt)
AAA
BBB
CCC
DDD
and there are 24 of these short words.
I am matching these patterns to another file with 755795 lines (file1.txt).
I have this code for matching:
awk -v f2=file2.txt '
BEGIN {
while(... (2 Replies)
Hey all,
I am parsing a file which have records containing one of a number of files names:
".psd", ".cr2", ".crw" , ".cr", ".xi", ".jpg", ".xif" etc
Somewhere on each line there is a value "Namex.psd" "Namex.crw" etc. The position of this name is highly variable
I need to output all the ".psd"... (4 Replies)