Thanks again. That worked from the command line when I added some empty single quotes after the -i. However, I'd like it to be executable from within a bash script, as it will be one stage in a longer conversion process. With sed scripts, I can reference the filename (passed in from cmd line) as $1, but I don't think that works with awk, as the $n syntax references fields. Is there an alternate way of referring to the filename?
I have some other questions about the syntax, for my own understanding:
...I assume here the & is acting as a concatenate operator, so this is saying "add the results of the following awk script to line 1 (1s) after all the existing characters (.*)" ?
match when text 'client' appears AND line number > 1 ?
...here my question is whether the ` quotes are the standard notation for delimiting an awk script that is feeding a sed script, or are they used because ' and " are already used elsewhere in the script? Or is it like with regex, where any character could be used to delimit, so long as it matches at both ends?
Also, what does the / at the end denote?
Thanks again for all your help, I am learning alot
OK, the saga continues. I am nearly done, but have this structure left, e.g.:
and I need to replace the line breaks in that last field with text '\n'. However when I use awk to access $s of line '/three/', I just get '"'.
I don't want to just replace all line breaks with '\n' in the file, because the ones at the end of lines one and two are not harming the input, whereas the ones in field three are (I'm trying to json_decode in PHP).
Hi, I wanted to add each row of file2.txt to entire length of file1.txt given the sample data below and save it as new file. Any idea how to efficiently do it. Thank you for any help.
input file
file1.txt file2.txt
140 30 200006 141 32
140 32 200006 142 33
140 35 200006 142... (5 Replies)
Hi ,
I have the below ouput,
=====gopi=====
assasassaa
adsadsadsdsada
asdsadsadasdsa
sadasdsadsd
=====kannan===
asdasdasd
sadasddsaasd
adasdd
=====hbk===
asasasssa
....
..
I want the output like as below, not able paste here correctly. (2 Replies)
Source File:
abcdefghijklmnop01qrstuvwxyz
abcdefghijklmnop02qrstuvwxyz
abcdefghijklmnop03qrstuvwxyz
abcdefghijklmnop04qrstuvwxyz
abcdefghijklmnop05qrstuvwxyz
Whatever characters are in 17-18 on each line of the file, it should be concatenated to the same line at the character number... (6 Replies)
I know this has been asked before but I just can't parse the syntax as explained. I have a set of files that has user information spread out over two lines that I wish to merge into one:
User1NameLast User1NameFirst User1Address
E-Mail:User1email
User2NameLast User2NameFirst User2Address... (11 Replies)
i am trying to append a 5 line SGML file(file1) with a 500,000 line SGML file (file2).
file1 is a template, so i wish to preserve.
i only want to add lines 5 to the end of file2.
i have:
cp file1 temp1
sed -n '5,$p' file2 >> temp1
when i check the tail of temp1, i consistantly find the... (3 Replies)
Have another question that has been eluding me all day.
I have data file I'm trying to reformat so that each line is appended with an ID code, but the ID code needs to update as it searches through the file.
I.e.
----Begin Original Datafile-----
Condition = XXX
Header Line 1
Header... (1 Reply)
:confused:
I have a script that Cats a flat database file which contains 12 columns into sed. I want to add a 13th column which includes " ,2005-08-29 " * The date needs to be the current date.
This 13th column would be appended to the end of each line.
Does anyone have a clue... (5 Replies)