04-16-2009
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
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
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
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
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
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
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
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
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
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 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
LEARN ABOUT DEBIAN
grdfilter
GRDFILTER(l) GRDFILTER(l)
NAME
grdfilter - Filter a .grd file in the Time domain
SYNOPSIS
grdfilter input_file.grd -Dflag -F<type><width> -Goutput_file.grd [ -Ix_inc[m|c][/y_inc[m|c]] ] [ -Rwest/east/south/north[r] ] [ -T ] [ -V
]
DESCRIPTION
grdfilter will filter a .grd file in the time domain using a boxcar, cosine arch, gaussian, median, or mode filter and computing distances
using Cartesian or Spherical geometries. The output .grd file can optionally be generated as a sub-Region of the input and/or with a new
-Increment. In this way, one may have "extra space" in the input data so that the edges will not be used and the output can be within one-
half- width of the input edges. If the filter is low-pass, then the output may be less frequently sampled than the input.
input_file.grd
The file of points to be filtered.
-D Distance flag tells how grid (x,y) relates to filter width as follows:
flag = 0: grid (x,y) same units as width, Cartesian distances.
flag = 1: grid (x,y) in degrees, width in kilometers, Cartesian distances.
flag = 2: grid (x,y) in degrees, width in km, dx scaled by cos(middle y), Cartesian distances.
The above options are fastest because they allow weight matrix to be computed only once. The next two options are slower because
they recompute weights for each East-West scan line.
flag = 3: grid (x,y) in degrees, width in km, dx scaled by cosine(y), Cartesian distance calculation.
flag = 4: grid (x,y) in degrees, width in km, Spherical distance calculation.
-F Choose one only of bcgmp for (b)oxcar, (c)osine Arch, (g)aussian, (m)edian, or maximum likelihood (p)robability (a mode estimator)
filter and specify full width.
-G output_file.grd is the output of the filter.
OPTIONS
-I x_inc [and optionally y_inc] is the output Increment. Append m to indicate minutes, or c to indicate seconds. If the new x_inc,
y_inc are NOT integer multiples of the old ones (in the input data), filtering will be considerably slower. [Default: Same as
input.]
-R west, east, south, and north defines the Region of the output points. [Default: Same as input.]
-T Toggle the node registration for the output grid so as to become the opposite of the input grid [Default gives the same registration
as the input grid].
-V Selects verbose mode, which will send progress reports to stderr [Default runs "silently"].
EXAMPLES
Suppose that north_pacific_dbdb5.grd is a file of 5 minute bathymetry from 140E to 260E and 0N to 50N, and you want to find the medians of
values within a 300km radius (600km full width) of the output points, which you choose to be from 150E to 250E and 10N to 40N, and you want
the output values every 0.5 degree. Using spherical distance calculations, you need:
grdfilter north_pacific_dbdb5.grd -Gfiltered_pacific.grd -Fm600 -D4 -R150/250/10/40 -I0.5 -V
SEE ALSO
gmt(1gmt), grdfft(1gmt)
1 Jan 2004 GRDFILTER(l)