Defining the single quotes outside awk since I was unable to escape them inside; double quotes around the single quotes to preserve them as text.
Handing over the shell variable $V to awk with the name v.
If NumberRecords (ie. the line number) equals 3
logical and
At the beginning of the lline of input is not the regular pattern ^boot (^ stands in this case for the beginning of the line)
Then do following command, ie. printing the string "boot =" and the value of the variable v
Also for all other lines awk finds, it shall just do it's default behaviour, which is printing. Shortest form to write is just a single number, in this case a 1.
And this is just the input file and the redirection after parsing into a new file
So in the case the patter is not found (boot...) in row 3, it will just do the 1, which is print.
If it is not found in row 3, it will print it.
Last edited by zaxxon; 06-10-2010 at 10:24 AM..
Reason: typo and logic correction
I need to create a fixed width file based on the column lengths.
lets assume I have six(this may be dynamic) fields each are of different length
column1=6 #size of the column
column2=3
column3=2
column4=3
column5=4
column6=5
I tried below code snippet but it is not working
echo... (4 Replies)
hi thanks a lot
But pls help me if my input file is the below format:
Name priya 2010-09-21 10:43:49
TEXT ID 1
hi
TEXT ID 2
how
TEXT ID 3
r
TEXT ID 4
u
Name2 priya2 2010-09-21 10:43:49
TEXT ID 1
hi1
TEXT ID 2
how1
TEXT ID 3
r1 (4 Replies)
Pls help in formatting a txt file using shell scripting
Input file format:
Name priya 2010-09-21 10:43:49
TEXT ID 1
hi
TEXT ID 2
how
TEXT ID 3
r
TEXT ID 4
u
Output required:
name priya hi how r u (4 Replies)
I am new ot unix. Is there one or two lines of command (sed may be) to format a file.
My source is..
<tag1>
<tag2>
<datatag1>
data1
</datatag1>
<datatag2>
data2
</datatag2>
<datatag3>
data3
</datatag3>
<datatag4>
data1
</datatag3>
</tag2>
</tag1> (2 Replies)
Hi,
I am new to unix , I have a requirement for formating the input file and generate the output file as per the downstream requirement ..
My application receiving a text input file having 4 field and my application need to check each field and if some value of a field is blank ..then it need... (1 Reply)
Hi,
I have a file with only data 1 row:
AA#?BB#?CC#?DD
Assume '#?' is the delimiter, i want the output in another file to be:
AA
BB
CC
DD
Pls let me know if this is possible by sed ?
Thanks in advance. (3 Replies)
I have two files file1 and file2 as shown below:
file1:
name
nameabc
bcd
nameabcdefg
file2:
age
age1111
age2345
age6743
I have pasted one file on the other with the delimiter "|" and the resulttant file is:
name|age
nameabc|age1111
bcd|age2345
nameabcdefg|age6743 (1 Reply)