awk-gsub on column-wise on each row


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk-gsub on column-wise on each row
# 1  
Old 12-13-2010
awk-gsub on column-wise on each row

awk '{ gsub(/....=/,""); print }' want.dat >final.dat

the above awk command which removes all the chars before and including '=' on the entire row. --thats what it meant be.Smilie

but i need to remove text on column-wise on each row.

many thanks,
EM

---------- Post updated at 10:00 AM ---------- Previous update was at 09:56 AM ----------

got a source data
Code:
ProductID=1	Name=Adjustable Race	ProductNumber=AR-5381	MakeFlag=0	FinishedGoodsFlag=0	Color=NULL	SafetyStockLevel=1000	ReorderPoint=750
ProductID=2	Name=Bearing Ball	ProductNumber=BA-8327	MakeFlag=0	FinishedGoodsFlag=0	Color=NULL	SafetyStockLevel=1000	ReorderPoint=750
ProductID=3	Name=BB Ball Bearing	ProductNumber=BE-2349	MakeFlag=1	FinishedGoodsFlag=0	Color=NULL	SafetyStockLevel=800	ReorderPoint=600

Code:
1	Adjustable Race	AR-5381	0	0	NULL	1000	750
2	Bearing Ball	BA-8327	0	0	NULL	1000	750
3	BB Ball Bearing	BE-2349	1	0	NULL	800	600


I need to remove the text before '=' including '=' till it hits the whitespace.

thanks for your help,
EM

Last edited by elamurugu; 12-13-2010 at 01:19 AM..
# 2  
Old 12-13-2010
Code:
sed 's/[[:graph:]]*=//g' want.dat

Code:
awk '{for (i=1;i<=NF;i++) gsub(/.*=/,"",$i)}1' OFS="\t" want.dat

This User Gave Thanks to rdcwayx For This Post:
# 3  
Old 12-13-2010
i feel that's a tricky one with sed..kudos rdcwayx Smilie
# 4  
Old 12-13-2010
Thank you..its inspiring me to learn more..you guys ROCK!
# 5  
Old 12-13-2010
Code:
sed 's/[^=\t]*=//g' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Parse output and then compare column wise with awk

Hello, I am trying to write a script to parse the output of data and then alert based on certain conditions This is the output of my script (STRING) Name = Joe (FLOAT64) BMI = 34 (FLOAT64) Weight = 156 (STRING) Name = Sam (FLOAT64) BMI = 32 (FLOAT64) Weight = 180 and so on it repeats... (4 Replies)
Discussion started by: sidnow
4 Replies

2. UNIX for Dummies Questions & Answers

Print row wise

Hi Help, I have an I/p, which looks like --- FF GG HH I want the o/p to be like --- FF GG HH. How we can do that? Thanks (7 Replies)
Discussion started by: Indra2011
7 Replies

3. Shell Programming and Scripting

Search/grep on row and column wise

Hello, I have a comma seperate metadata as follows: CITY ,COUNTY,STATE,COUNTRY NEW_YORK,NYC ,NY ,USA NEWARK ,ESSEX ,NJ ,USA CHICAGO ,COOK ,IL ,USA SEATTLE ,MINER ,WA ,USA In my process, I get two key values ie CITY NAME (can be one of the... (7 Replies)
Discussion started by: calredd
7 Replies

4. UNIX for Dummies Questions & Answers

awk to print first row with forth column and last row with fifth column in each file

file with this content awk 'NR==1 {print $4} && NR==2 {print $5}' file The error is shown with syntax error; what can be done (4 Replies)
Discussion started by: cdfd123
4 Replies

5. UNIX for Dummies Questions & Answers

Changing the values of a column using awk and gsub

Hi, I am using the following code to change NA to X in only the 5th column of my text file: awk '{gsub("NA","x",$5)}1' in.file > out.file How can I modify this code if I want to change NA to X in multiple columns of the text file (i.e. columns 5,6 and 7). Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

6. Shell Programming and Scripting

calculating row-wise standard deviation using awk

Hi, I have a file containing 100,000 rows-by-120 columns and I need to compute for the standard deviation for each row. Any idea on how to calculate row-wise standard deviation using awk? My sample data looks like this: input data: 23 35 12 25 16 17 18 19 29 12 12 26 15 14 15 23 12 12... (2 Replies)
Discussion started by: ida1215
2 Replies

7. Shell Programming and Scripting

Subtracting each row from the first row in a single column file using awk

Hi Friends, I have a single column data like below. 1 2 3 4 5 I need the output like below. 0 1 2 3 4 where each row (including first row) subtracting from first row and the result should print below like the way shown in output file. Thanks Sid (11 Replies)
Discussion started by: ks_reddy
11 Replies

8. Shell Programming and Scripting

Loop for row-wise averaging of multiple files using awk

Hello all, I need to compute a row-wise average of files with a single column based on the pattern of the filenames. I really appreciate any help on this. it would just be very difficult to do them manually as the rows are mounting to 100,000 lines. the filenames are as below with convention as... (2 Replies)
Discussion started by: ida1215
2 Replies

9. Shell Programming and Scripting

Get value of last row and 6 column from awk

I want to get value of last row and 6 column from awk. Below is the format of my file. And RED one is my desired value. Actaully this stats usally update after every 1 hour so i want that every time i run the script i get the latest value. Ending time - 01:00:58 HOURLY CALL ATTEMPTS... (4 Replies)
Discussion started by: wakhan
4 Replies

10. Shell Programming and Scripting

Unix addition ( Row wise)

Hi I have a file like a,1 b,2 d,3 a,2 b,3 c,7 Result Desired: a,3 b,5 d,3 c,7 i.e on the bases of 1st field the addition is done of the 2nd field and result printed out. (3 Replies)
Discussion started by: gauravgoel
3 Replies
Login or Register to Ask a Question