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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Line replacement

Status
Not open for further replies.

job357

Technical User
Sep 16, 2002
106
US
Hello,
I have a file that has a line that i need to replace, the line is as follows exactly:

"e641",, 20030101, 20030101, "043900", "ERR"^M

I need this line replaced with:

"e641",,,,"",""

Thanks,
Travis
 
Try this:
Code:
awk -F, '
$6=="ERR"{printf "%s,,,,\"\",\"\"",$1;next}
{print}
' <InputFile >OutputFile

Hope This Help
PH.
 
Thanks,
I am going to try this and let you know, thanks again.
 
Sorry,
But I am getting an error when running this command againt the file:

Usage: awk [POSIX or GNU style options] -f progfile [--] file ...
awk [POSIX or GNU style options] [--] 'program' file ...
POSIX options: GNU long options:

As if the syntax is incorrect?
 
Works for me on Aix 4 ( and on 3.25)
Have you got nawk or gawk - try that instead
NB - I included a \n in the printf template

awk -F, '
$6==&quot;ERR&quot;{printf &quot;%s,,,,\&quot;\&quot;,\&quot;\&quot;\n&quot;,$1;next}
{print}
' InputFile >OutputFile

Dickie Bird (:)-)))
 
Try this:
Code:
awk 'BEGIN{FS=&quot;,&quot;}
$6==&quot;ERR&quot;{printf &quot;%s,,,,\&quot;\&quot;,\&quot;\&quot;\n&quot;,$1;next}
{print}
' <InputFile >OutputFile
Thanks dickiebird for the correction.

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top