script change column 22

March 27, 2009 at 03:24:13
Specs: Solaris
A recent change means that the sql being produced has too much text in column 22 for the target system which is limited to 30 characters. I need to know how to post process the sql file to truncate whatever is in field 22 to the 30 leftmost characters. The INSERT command is every third line. Thanks

See More: script change column 22

Report •

March 27, 2009 at 09:34:11
Since your OS is Solaris, are you asking for a unix shell script to do the post processing? If so, this awk script grabs the first 30 characters of field 22, resets field 22 to these values and prints the record:


# untested for 22 columns
awk ' {
print $0
} ' mysqlfile > mynewsqlfile

Report •

March 27, 2009 at 10:18:40
Thanks nails. I'm not sure what to do about the other 2 lines. One does an insert in another database and the other is a comit command. Obviously I don't want to change these lines with the script. This requires some "if" and "where" presumably?

Report •

Related Solutions

Ask Question