In a directory, there are two different file extensions (*.txt and *.xyz) having similar names of numerical strings (*). The (*.txt) contains 5000 multiple files and the (*.xyz) also contains 5000 multiple files. Each of the files has around 4000 rows and 8 columns, with several unique string patterns at 5th column.
Files *.txt
Files *.xyz
3.txt
3.xyz
Tasks:
(Step-1) At 5th column of '3.xyz' file, find all matching patterns in '3.txt' file.
(Step-2) Write the entire row into a new file, based on the condition in step-1 above.
This is how the output looks like:
newfile.dat
I tried awk to get the expected output, such that it creates a field array and compares file *.txt with file *.xyz and prints the corresponding matching values into a new file.
And, for iteration to multiple files in directory:
Awk error shows 'unterminated string', yet I check the code and coudnt find solution. Please help.
Thanks, Pravin for the helpful reply. The code work perfectly at command prompt. Would you please further help on how to do an iteration script for multiple files in directory using the code you gave ? I tried this:
The $.xyz and $.txt have same numeric string, and only file extension differs.
The EF_$d is to write the output correspondingly.
Delete patterns matching
OS version: RHEL 7.3
Shell : Bash
I have a file like below (pattern.txt). I need to delete all lines starting with the following words (words separated by comma below) and ) character.
LOGGING, NOCOMPRESS, TABLESPACE , PCTFREE, INITRANS, MAXTRANS, STORAGE,... (3 Replies)
Hello.
For a given folder, I want to select any files find $PATH1 -f \( -name "*" but omit any files like pattern name ! -iname "*.jpg" ! -iname "*.xsession*" ..... \) and also omit any subfolder like pattern name -type d \( -name "/etc/gconf/gconf.*" -o -name "*cache*" -o -name "*Cache*" -o... (2 Replies)
Hi,
I have multiple files in my log folder. e.g:
a_m1.log
b_1.log
c_1.log
d_1.log
b_2.log
c_2.log
d_2.log
e_m1.log
a_m2.log
e_m2.log
I need to keep latest 10 instances of each file.
I can write multiple find commands but looking if it is possible in one line.
m file are monthly... (4 Replies)
Hello all,
I have since given up trying to figure this out and used sed instead, but I am trying to understand awk and was wondering how someone might do this in awk.
I am trying to match on the first field of a specific file with the first field on multiple files, and append the second field... (2 Replies)
Hi,
I have requirement to find the matching patterns of two files in Unix. One file is the log file and the other is the error list file. If any pattern in the log file matches the list of errors in the error list file, then I would need to find the counts of the match.
For example,
... (5 Replies)
Hi,
I wasn't quite sure how to title this one! Here goes:
I have some already partially parsed log files, which I now need to extract info from. Because of the way they are originally and the fact they have been partially processed already, I can't make any assumptions on the number of... (8 Replies)
Hi Folks,
I have two arrays
a:
aaa bbb ccc ddd
ddd aaa bbb ccc
ddd ccc aaa bbb
b:
aaa bbb ccc
aaa ccc bbb
bbb aaa ccc
ccc bbb aaa
I want to compare row by row a(c1:c4) to b(c1:c3). If elements of 'b' match... (5 Replies)
Dear awk users,
I am trying to use awk to match records across two moderately large CSV files. File1 is a pattern file with 173,200 lines, many of which are repeated. The order in which these lines are displayed is important, and I would like to preserve it. File2 is a data file with 456,000... (3 Replies)
I have the following in an awk script. I want to do them on condition that: fext == "xt"
FNR == NR {
/>/ && idx = ++i
$2 || val = $1
next
}
FNR in idx { v = val] }
{ !/>/ && srdist = abs($1 - v) }
/>/ || NF == 2 && srdist < dsrmx {... (1 Reply)
I have a file name in $f. If $f has "-" at the beginning, or "=", or does not have extension ".ry" or ".xt" or ".dat" then cerr would not be empty.
Tried the following but having some problems.
set cerr = `echo $f | awk '/^-|=|!.ry|!.xt|!.dat/'` (4 Replies)