Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text manipulation 1

Status
Not open for further replies.

IMAUser

Technical User
May 28, 2003
121
CH
Hi All,

I have a file with a lot of records like the following

SQL> SQL> SQL> SQL> SQL> SQL> SQL> 2 3 4 5 6 7 8 9 10 11 INSERT INTO table_dd VALUES ('XXXXXXXXXXX','EV','FI','','1005','05-JUN-03','1')

(That is one line without a CR in between).
I need to take away all the text from the word INSERT onwards till the end of the line and generate a script out of it. This script will have a char backslash( / ) on a new line after every line of INSERT statement.
Also, this is not fixed position, so the word INSERT may not start at the same position for every record and the number of junk chars may vary on every line before the word INSERT.

Any help appreciated.
Thanks,
 


nawk -f insert.awk -myFile.txt

#---------------- insert.awk
match($0, "INSERT") { $0=substr($0, RSTART); printf("%s\n/\n", $0) }

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Unbelieveable stuff. I was kind of preparing myself for a huge program doing all kinds of things. Didnt expect it to be done in a single stroke.

Thanks a ton.
 
actually it should be:

nawk -f insert.awk myFile.txt

#---------------- insert.awk
match($0, &quot;INSERT&quot;) { printf(&quot;%s\n/\n&quot;, substr($0, RSTART)) }

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top