03-04-2008
awk help urgent
Hi
i am trying to read a line from a file and add the values in a new file
eg
Input file
a1|a2|a3|a4|a5|a6
b1|b2|b3|b4|b5|b6
c1|c2|c3|c4|c5|c6
expected output
File one
a1|a2|a3
b1|b2|b3
c1|c2|c3
file two
a1|a4
a1|a5
a1|a6
b1|b4
b1|b5
b1|b6
c1|c4
c1|c5
c1|c6
Please help.
Thanks
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
i have a record like
1,23423,4545,6767,89898,3434,121212,123123,322
2,23233,3434,4545,56566,rxrx,e344343,343434,3434
1,23223,336,78787,78787,654,6767677,6877989,7878
i want to check the $6 field if its start with any letters, i want to move this record to some other file and keep rest of... (2 Replies)
Discussion started by: readycpbala
2 Replies
2. Shell Programming and Scripting
Hi
I have a file which is having following text. The file is in a tabular form with 5 fields. i.e field1, field2 ..... field5 are its columns and there are many rows in it say COUNT is the number of rows
Field 1 Field2 Field3 Field4 Field5
------- ------- ... (8 Replies)
Discussion started by: skyineyes
8 Replies
3. Shell Programming and Scripting
Thank everyone advanced.
Would you please tell me how to use the shell variable in the awk body?
I try follows but they all do not work, pls kindly help me:
1.
str=`cat file2`
awk 'BEGIN{print("'"$str"'"}' file1 > file3
2.
str=`cat file2`
awk 'BEGIN{print(ENVIRON}' file1 > file3
3.... (3 Replies)
Discussion started by: summer_cherry
3 Replies
4. Shell Programming and Scripting
Guys
I have the file TEST.csv generated after a join of two different files with the same columns:
key,string,data,number,key,string,data,number
abc,test,020202,3,abc,test,010305,4
abc,level,070202,9,abc,tool,010203,7
def,tool,010101,7,,,,
ghi,,,ghi,test,010203,8
I have to generate a... (2 Replies)
Discussion started by: Rafael.Buria
2 Replies
5. Shell Programming and Scripting
Hi All,
I am a beginner to Unix. So would really appreciate if people out here can help me out.
I have a XML file which has a element <NoteData> in which two values DBHA and DAKO.
I need to search these in all the XML files in a directory and if found in the XML file then replace the... (3 Replies)
Discussion started by: karansachdeva
3 Replies
6. Shell Programming and Scripting
Hi
I have a scenario where i have a file name as
abcd_To_hfgh.20090456778_1.dat
I will get the filename as parameter
and i need a string in between second _ and first . i.e i need hfgh in this case.
Please help me with the script. This may not be awk script even if it can be... (2 Replies)
Discussion started by: dsdev_123
2 Replies
7. Shell Programming and Scripting
Hi All,I need to convert following field from a file
L2578978CLC/576/116804 => L2578978CLC/00000576/00168304
i have to append Zeros in the third and fourth number after slash / in the above string (total length of number should be 8).
means L2578978CLC/576/116804 should be converted to... (3 Replies)
Discussion started by: unknown123
3 Replies
8. Shell Programming and Scripting
Hello,
I have a file with the follwoing pattern:
Input file:
===========
tcp://xxx:123
8179 YY
1798 YY
tcp://abc:2345
not found
tcp://swt:4945
7356 QQ
tcp://pqr:456
8178 PP
9485 PP
4485 PP (8 Replies)
Discussion started by: uandme2k2
8 Replies
9. Shell Programming and Scripting
Hi,
Sample Input
Table 1 XXXXX YYYYY
A 1 2 3 4 5
B 1 2 3 4 5
C 1 2 3 4 5
D 1 2 3 4 5
A 6 7
B 6 7
C 6 7
D 6 7
Table 2 XXXXX YYYYY
E 1 2 3 4 5
F 1 2 3 4 5
E 6 7
F 6 7
Table 3 XXXXX YYYYY
G 1 2 3 4 5 (4 Replies)
Discussion started by: ravin
4 Replies
JOIN(1) General Commands Manual JOIN(1)
NAME
join - relational database operator
SYNOPSIS
join [ options ] 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.
-jn m Join on the mth field of file n. If n is missing, use the mth field in each file.
-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)