Pls help me with file editing using awk


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Pls help me with file editing using awk
# 1  
Old 09-16-2008
Pls help me with file editing using awk

Hi all,
Pls help me with file editing using awk.
I have a text file with the below format.

"STANDARD VOLUME ","2009","BUX","V","JCBH49","NF", 001413
"VENDOR MATERIAL-STD ","2009","BUX","V","JCBH49","NF", 009948
"INBOUND TRANS-STD ","2009","BUX","V","JCBH49","NF", 000264
"DIRECT LABOR-STD ","2009","BUX","V","JCBH49","NF", 000010
"VARIABLE BURDEN-STD ","2009","BUX","V","JCBH49","NF", 000062
"FIXED BURDEN-STD ","2009","BUX","V","JCBH49","NF", 000081

Here I want to retrieve the records of only "VENDOR MATERIAL-STD "and write to another text file. Also I want to replace "V" with “Prod Matl Cost PU Base Vehicle” and "O" with “Prod Matl Cost PU Avg Option” while writing to another file.

Thanks in advance.
# 2  
Old 09-16-2008
try:
Code:
sed -n -e '/VENDOR MATERIAL-STD/ { s/"V"/Prod Matl Cost PU Base Vehicle”/ ; s/"O"/“Prod Matl Cost PU Avg Option”/ ; p }' filename > newfile

# 3  
Old 09-16-2008
Thanks Yogesh.

I tried the below and got the below message.

#!/bin/ksh
sed -n -e '/VENDOR MATERIAL-STD / { s/"V"/Prod Matl Cost PU Base Vehicle./ ; s/"O"/.Prod Matl Cost PU Avg Optio
n./ ; p }' /clocal/fme/essbase/data/cash/goldbooklesspowertrain.txt > /clocal/fme/essbase/data/cash/newgoldbooklesspowertrain.
txt

Message:

sed: command garbled: /VENDOR MATERIAL-STD / { s/"V"/Prod Matl Cost PU Base Vehicle./ ; s/"O"/.Prod Matl Cost PU Avg Option./ ; p }
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

editing file with awk cut and sed

HI All, I am new to unix. I have a file would like to do some editing by using awk, cut and sed. Could anyone help? This file contain 100 lines. There are one line for example: 2,"102343454",5060,"579668","579668","579668","SIP",,,"825922","035885221283026",1,268,"00:59:00.782 APR 17... (2 Replies)
Discussion started by: mimilaw
2 Replies

2. Shell Programming and Scripting

Problems editing file with awk in bash script

Hello dear users, here I have a script to manipulate .csv files that are like this originally: And I need to make a script to delete certain fields. Each field is separated with a comma. So, here is my script (at least a part of it): Field $1 is composed of a name, and then a... (5 Replies)
Discussion started by: sr00t
5 Replies

3. Shell Programming and Scripting

Comparison and editing of files using awk.(And also a possible bug in awk for loop?)

I have two files which I would like to compare and then manipulate in a way. File1: pictures.txt 1.1 1.3 dance.txt 1.2 1.4 treehouse.txt 1.3 1.5 File2: pictures.txt 1.5 ref2313 1.4 ref2345 1.3 ref5432 1.2 ref4244 dance.txt 1.6 ref2342 1.5 ref2352 1.4 ref0695 1.3 ref5738 1.2... (1 Reply)
Discussion started by: linuxkid
1 Replies

4. Shell Programming and Scripting

use awk to edit a file..pls help

hey i want to over write the fourth field of a ':' delimited file by first finding the required row by using grep. i have done the following cat file | grep no. | awk -F ':' { $4=count; print $1:$2:$3:$4;} the correct values are being printed but nothin is bein added to the file..please... (5 Replies)
Discussion started by: dhe.arora
5 Replies

5. Shell Programming and Scripting

scripting/awk help : awk sum output is not comming in regular format. Pls advise.

Hi Experts, I am adding a column of numbers with awk , however not getting correct output: # awk '{sum+=$1} END {print sum}' datafile 2.15291e+06 How can I getthe output like : 2152910 Thank you.. # awk '{sum+=$1} END {print sum}' datafile 2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies

6. Shell Programming and Scripting

AWK - HELP pls explain this ?

echo "23.54" | awk ' function round(A) { return int( A + 0.5 ) } { printf("%d\n",round($1)); }'> > > > > > awk: syntax error near line 2 awk: bailing out near line 2 (2 Replies)
Discussion started by: santosh1234
2 Replies

7. Shell Programming and Scripting

Help needed in 'awk' : pls.

we have a file File1.I have used the below code to append 'file1' to each row.it is appending 'file1' but there is 5 empty space is coming after the end of each row.i found this opening in 'vi' mode and moving the cursor on each row ...can u help me ... File1: E100|0|05/29/1993|0|E001|E000... (3 Replies)
Discussion started by: satyam_sat
3 Replies

8. Shell Programming and Scripting

Editing File using awk/sed

Hello Awk Gurus, Can anyone of you help me with the below problem. I have got a file having data in below format pmFaultyTransportBlocks ----------------------- 9842993 pmFrmNoOfDiscRachFrames ----------------------- NULL pmNoRecRandomAccSuccess -----------------------... (4 Replies)
Discussion started by: Mohammed
4 Replies

9. Shell Programming and Scripting

Editing the File using Awk

I have input file that is having below text 098769 178902 234678 I want to modify the input file like below. '098769', '178902', '234678' Can you please help to get this. I tried but i am not getting this. (3 Replies)
Discussion started by: awk_beginner
3 Replies

10. Shell Programming and Scripting

File editing using awk

Hi All, I have a file, say test.dat which is "|" separated. It has 50K records in it. One of the field in the file has the data in the format 'mm/dd/yyyy'. I need to edit the file by changing the format to 'yyyy/mm/dd' in the same field where as the rest of the data remain untouched. Please... (2 Replies)
Discussion started by: rinku11
2 Replies
Login or Register to Ask a Question