HI I HAVE A PROBLEM,MY SOURCE FILE IS OF PATTERN
S1,E-Certified,29,29,2.7,Certified,4,3,2.7,,0,0,0
S2,Certified,4,3,2.7,,0,0,0,,0
S3,E-Certified,29,29,2.7,,0,0,0
S4,,0,0,0,,0,0,0,,0,0,0,,0,0,0
THE NUMBER OF FIELDS(NF) IN SOURCE FILE MAY BE MORE THAN 500. WHEREEVER THE FIRST NULL VALUE COMES IT SHOULD TRUNCATE THE ROW.
I TRIED TO SOLVE N WROTE THIS CODE,
bUT THE OUTPUT COMING IS
S1,E-Certified,29,29,2.7
S1,Certified,4,3,2.7
S1,S2,Certified,4,3,2.7
S2,S3,E-Certified,29,29,2.7
S3,
I AM NOT ABLE TO FIND OUT THE ERROR. IF ANYONE FINDS ANY PROBABLE SOLUTION PLZ SUGGEST ME.
I Solved the problem. The code should be
awk -F\, '{
if ($2!="") printf$1FS fi;c=0
for(i=2;i<=NF;i++)
{
if ($i=="") i+=NF fi;
printf$i ($i!=""?++c%4?i==NF?RS:FS$(i+1)!=""?RS$1FS:RS):EXIT);
}
}'
Last edited by pkumar3; 10-15-2008 at 01:49 AM..
Reason: added code tags
how to change a particular value in a line of a file based on a pattern
eg:
source file will be like
=================
99999999999 maximum number(0)
ksuisikjjsl;;l skjss''llsl
minimum number 0000000
maximum number of golds(0)
target should be like
=================
... (9 Replies)
My input:
File_1:
2000_t
g1110.b1
abb.1
2001_t
g1111.b1
abb.2
abb.2
g1112.b1
abb.3
2002_t
.
.
File_2:
2000_t Ali england 135
abb.1 Zoe british 150
2001_t Ali england 305
g1111.b1 Lucy russia 126 (6 Replies)
Hi,
I need to truncate a file based on date.Suppose i have a log file which is getting updated every date,i need to keep 7 days worth of data(like sysdate-7) and rest i want to truncate it.Can some help me? (5 Replies)
I have a binary (hex) file I need to parse to get some data which are encoded this way:
.* b4 . . . 01 12 .* af .* 83 L1 x1 x2 xL 84 L2 y1 y2 yL
By another words there is a stream of hexadecimal bytes (in my example separated by space for better readability). I need to get value stored in... (3 Replies)
Hi,
I have a data file with :
01/28/2012,1,1,98995
01/28/2012,1,2,7195
01/29/2012,1,1,98995
01/29/2012,1,2,7195
01/30/2012,1,1,98896
01/30/2012,1,2,7083
01/31/2012,1,1,98896
01/31/2012,1,2,7083
02/01/2012,1,1,98896
02/01/2012,1,2,7083
02/02/2012,1,1,98899
02/02/2012,1,2,7083
I... (1 Reply)
Hi there, I am pretty new to those things, so I couldn't figure out how to solve this, and if it is actually that easy. just found that awk could help:(.
so i have a textfile with strings and numbers (originally copy pasted from word, therefore some empty cells) in the following structure:
SC... (9 Replies)
if it is finding some data based on pattern 'test' then insert else if has no data based on the pattern 'test' then exit successfully
cat file | grep test > file2 (3 Replies)
Hello All,
I have multiple files in a hadoop /tmp/cloudera directory.
Filename are as follows
ABC_DATA_BAD5A_RO_F_20161104.CSV
ABC_DATA_BAD6C_VR_F_20161202.CSV
ABC_DATA_BAD7A_TR_F_20162104.CSV
ABC_DATA_BAD2A_BR_F_20161803.CSV
ABC_DATA_BAD3T_KT_F_20160106.CSV
I just need filenames... (6 Replies)
Hi All,
I want to create a new file based on certain conditions and copy only those conditioned data to new file.
Input Data is as it looks below.
ORDER|Header|Add|32|32|1616
ORDER|Details1.........
ORDER|Details2.........
ORDER|Details3.........
ORDER|Details4............ (10 Replies)
We have the data looks like below in a log file.
I want to generat files based on the string between two hash(#) symbol like below
Source:
#ext1#test1.tale2 drop
#ext1#test11.tale21 drop
#ext1#test123.tale21 drop
#ext2#test1.tale21 drop
#ext2#test12.tale21 drop
#ext3#test11.tale21 drop... (5 Replies)