Sponsored Content
Top Forums UNIX for Dummies Questions & Answers SED command to search for numeric and replace Post 302307723 by ajayh on Thursday 16th of April 2009 07:52:30 AM
Old 04-16-2009
Java SED command to search for numeric and replace

Hi

I am very new to linux and scripting.

I need to replace numbers abc with number xyz inputting from a reference file.
I used the following command -
sed "s/$grd/$lab/" , where $grd and $lab comes from reference file.

The problem is the above line doesnt take care of space..
eg- 1546745 12344 123
if i need to replace 123 with 666 => grd = 123, lab = 666
following is the result -
1546745 66644 666
THe required result is - 1546745 12344 666

the script shud recognise spaceNumberspace and then replace only.

Any help wud be appreciated.

Thanks,
Aj
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed search and replace

Hello Folks, Anyone know how I can replace this line in file.xml <oacore_nprocs oa_var="s_oacore_nprocs">8</oacore_nprocs> with this line <oacore_nprocs oa_var="s_oacore_nprocs">1</oacore_nprocs> using sed or awk ? Thanks for your time. Cheers, Dave (7 Replies)
Discussion started by: d__browne
7 Replies

2. UNIX for Dummies Questions & Answers

Search/Replace with Sed

Is there a way to use the sed command to 1) search a specified pattern 2) in the line where that pattern is found, replace from character N to character N+4 with a new 4-character string. Thks in advance! (5 Replies)
Discussion started by: mvalonso
5 Replies

3. Shell Programming and Scripting

sed search and replace command

Hi, I would like to seek help on how i can arrive on this result. sample.txt: product_code IN (param001) and product_type IN (param004) product_code IN (param002) and product_type IN (param005) product_code IN (param003) and product_type IN (param006) I would like to change the param001... (1 Reply)
Discussion started by: janzper
1 Replies

4. UNIX for Dummies Questions & Answers

How to search and replace a particular line in file with sed command

Hello, I have a file and in that, I want to search for a aprticular word and then replace another word in the same line with something else. Example: In file abc.txt, there is a line <host oa_var="s_hostname">test</host> I want to search with s_hostname text and then replace test with... (2 Replies)
Discussion started by: sshah1001
2 Replies

5. Shell Programming and Scripting

sed search and replace

hi, im new for sed, anyone can help me to these in sed command my output file.txt "aaa",a1,bbb "ddd",a1,ccc "eee",a1,www need to change a1, to "a1"," output i need "aaa","a1","bbb "ddd","a1","ccc "eee","a1","www thanks in advance fsp (2 Replies)
Discussion started by: fspalero
2 Replies

6. UNIX for Dummies Questions & Answers

Find and Replace random numeric value with non-numeric value

Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is: 1702938475,SNU022,201004 the first 10 numbers always begin with 170 (6 Replies)
Discussion started by: Bahf1s
6 Replies

7. UNIX for Dummies Questions & Answers

How to use 'sed' to search and replace?

Hello - I have a very large file in which a certain numbers are repeated. I find that using vi to edit the entire file is useless. How should i use sed to find a replace such as this text: To replace: 145.D25.D558 With: 215.22.45.DW I tried this command: sed... (4 Replies)
Discussion started by: DallasT
4 Replies

8. Shell Programming and Scripting

search and replace with sed command

hi, suggest me in the below script.. if In above I wanna replace "" with "]". (2 Replies)
Discussion started by: divya bandipotu
2 Replies

9. Shell Programming and Scripting

Sed - search and replace help.

Hi everyone, basically I am been cleaning data by using simple sed commands So what i have below has been working for me. sed 's/="//g' trade.csv > tradeb.csv sed 's/"//g' tradeb.csv > trade2.csv but now i don't want to remove all the quotes just the ones if i encounter this ... (1 Reply)
Discussion started by: raz0r
1 Replies

10. Shell Programming and Scripting

How to search and replace string in column in file with command sed?

how to search and replace string in column in file with command sed or other search "INC0000003.in" and replace column 4 = "W" $ cat file.txt INC0000001.in|20150120|Y|N|N INC0000002.in|20150120|Y|N|N INC0000003.in|20150120|Y|N|N INC0000004.in|20150120|Y|N|Noutput... (4 Replies)
Discussion started by: ppmanja3
4 Replies
GRDEDIT(l)																GRDEDIT(l)

NAME
grdedit - Modifying the header in a 2-D grdfile SYNOPSIS
grdedit grdfile [ -A ] [ -Dxunit/yunit/zunit/scale/offset/title/remark ] [ -Rwest/east/south/north[r] ] [ -S ] [ -V ] DESCRIPTION
grdedit reads the header information in a binary 2-D grdfile and replaces the information with values provided on the command line [if any]. As an option, global, geographical grids (with 360 degrees longitude range) can be rotated in the east-west direction. grdedit only operates on files containing a grdheader. No space between the option flag and the associated arguments. Use upper case for the option flags and lower case for modifiers. grdfile Name of the 2-D grdfile to modify OPTIONS
-A If necessary, adjust the file's x_inc, y_inc to be compatible with its domain (or a new domain set with -R). Older gridfiles (i.e., created prior to GMT 3.1) often had excessive slop in' x_inc, y_inc and an adjustment is necessary. Newer files are created cor- rectly. -D Give new values for xunit, yunit, zunit, scale, offset, title, and remark. To leave some of the values untouched, specify = as the new value. -R west, east, south, and north specify the Region of interest. To specify boundaries in degrees and minutes [and seconds], use the dd:mm[:ss] format. Append r if lower left and upper right map coordinates are given instead of wesn. The new w/e/s/n values will replace those in the grid, and the x_inc, y_inc values are adjusted, if necessary. -S For global, geographical grids only. Grid values will be shifted laterally according to the new borders given in -R. -V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"]. EXAMPLES
Let us assume the file data.grd covers the area 300/310/10/30. We want to change the boundaries from geodetic longitudes to geographic and put a new title in the header. We accomplish this by grdedit data.grd -R-60/-50/10/30 -D=/=/=/=/=/"Gravity Anomalies"/= The grid world.grd has the limits 0/360/-72/72. To shift the data so that the limits would be -180/180/-72/72, use grdedit world.grd -R-180/180/-72/72 -S The file junk.grd was created prior to GMT 3.1 with incompatible -R and -I arguments. To reset the x- and y-increments we run grdedit junk.grd -A SEE ALSO
gmt(1gmt), grd2xyz(1gmt), xyz2grd(1gmt) 1 Jan 2004 GRDEDIT(l)
All times are GMT -4. The time now is 02:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy