Tried the below nawk and it worked, but still i have one issue pending
if i use "for" loop to get "abcxx" then it displays multiple entries.
I think we have a language barrier. Your specification of what you want done is not clear.
You say you want to match abcxx, but none of your input lines contains the string "abcxx".
You say that you want to change the second column, but you say that there are three tab spaces (whatever that means) and that the tab spaces have to be preserved. If you mean that there are three tab characters between the 1st field and the field that contains TRUE and that you want each tab character to be treated as a field separator, then say that the tab character is your field separator and you want the 4th field set to TRUE if abcxx appears in field 1 and you want the 4th field set to FALSE if abcxx does not appear in field 1.
If by abcxx you mean that you want to match the string "abc" immediately followed by two decimal digits, then you need to match against "abc[0-9][0-9]"
instead of matching against "abcxx".
And, awk (nawk on Solaris systems) matches extended regular expressions, not just fixed strings.
----------------
And, I forgot to ask why you need a for loop to get the constant "abcxx"???
Last edited by Don Cragun; 12-17-2012 at 01:30 AM..
Reason: Forgot about for loop question.
Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2
file 1 sample
SNDK 80004C101 AT
XLNX 983919101 BB
NETL 64118B100 BS
AMD 007903107 CC
KLAC 482480100 DC
TER 880770102 KATS
ATHR 04743P108 KATS... (7 Replies)
Hello,
I am trying to replace the column in file1 with the column from file2. The two files will have the same amount of rows. Each row will correspond with the same row in the other file.
File1
"Replace this column"
500 13-APR-2011... (11 Replies)
Hi friends,
My file is like:
Second file is :
I need to print the rows present in file one, but in order present in second file....I used
while read gh;do
awk ' $1=="' $gh'" {print >> FILENAME"output"} ' cat listoffirstfile
done < secondfile
but the output I am... (14 Replies)
I have a csv file with occasional multiple entries in the second column.
111111,104,07-24-2011,3.15,N,
222222,020 140,07-24-2011,10.00,N,I want the result
111111,104,07-24-2011,3.15,N,
222222,020,07-24-2011,10.00,N,
222222,140,07-24-2011,10.00,N,
I know I can get the output of the second... (5 Replies)
Hi experts,
My csv file looks like this
U;cake;michael;temp;;;;
U;bread;john;temp;;;;
U;cocktails;sarah;temp;;;;
I'd like to change the value fo 2nd column to cf+random number , which will look maybe something like this
U;cf20187;michael;temp;;;;
U;cf8926;john;temp;;;;... (7 Replies)
Can anyone please help with this? I have 2 files as given below.
If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value.
file1
abc_1 foo1@a ....
abc_1 soo2@a ...
def_2 soo2@a ....
def_2 foo1@a ........ (7 Replies)
Legends,
I have following entries in a file.
I want to toggle the entry of 2nd column. TRUE/FALSE
i tried using perl -p -i -e
but the problem is, if instead of "tab" space after 1st column, there is a character or multi character space then this won't work.
perl -p -i -e... (6 Replies)
Dear All,
I have data like this,
input.txt
A 0B 1828
C 100D 1666,C 200D 1727,C 300D 1783,
A 0B 1786
C 200D 1727,C 100D 1666,C 300D 1783,
C 400D 1812,C 600D 1869,C 500D 1841,
C 400D 1812,C 500D 1841,C 600D 1869,
A 0B 1349
C 200D 1727,C 300D 1783,C 100D... (1 Reply)
I am looking at the NR==FNR posts and trying to use them to achieve the following but I am not getting it.
I have 2 files. I want to match column 8 in file 1 with column 2 in file 2. When they match I want to replace column 9 in file 1 with column 1 in file 2.
This is and extract from file 1
... (5 Replies)
hi
I have 2 file with more than 10 columns for both
1st file
apple,0,0,0......
orange,1,2,3.....
mango,2,4,5.....
2nd file
apple,2,3,4,5,6,7...
orange,2,3,4,5,6,8...
watermerlon,2,3,4,5,6,abc...
mango,5,6,7,4,6,def.... (1 Reply)
Discussion started by: tententen
1 Replies
LEARN ABOUT MINIX
join
JOIN(1) General Commands Manual JOIN(1)NAME
join - relational database operator
SYNOPSIS
join [-an] [-e s] [-o list] [-tc] file1 file2
DESCRIPTION
Join forms, on the standard output, a join of the two relations specified by the lines of file1 and file2. If file1 is `-', the standard
input is used.
File1 and file2 must be sorted in increasing ASCII collating sequence on the fields on which they are to be joined, normally the first in
each line.
There is one line in the output for each pair of lines in file1 and file2 that have identical join fields. The output line normally con-
sists of the common field, then the rest of the line from file1, then the rest of the line from file2.
Fields are normally separated by blank, tab or newline. In this case, multiple separators count as one, and leading separators are dis-
carded.
These options are recognized:
-an In addition to the normal output, produce a line for each unpairable line in file n, where n is 1 or 2.
-e s Replace empty output fields by string s.
-o list
Each output line comprises the fields specified in list, each element of which has the form n.m, where n is a file number and m is a
field number.
-tc Use character c as a separator (tab character). Every appearance of c in a line is significant.
SEE ALSO sort(1), comm(1), awk(1).
BUGS
With default field separation, the collating sequence is that of sort -b; with -t, the sequence is that of a plain sort.
The conventions of join, sort, comm, uniq, look and awk(1) are wildly incongruous.
7th Edition April 29, 1985 JOIN(1)