Hi,
I am reading a file (GC_JAR.log) which has entries like:
320325.566, 0.0453191 secs]
I want to replace all the entries of "secs]" with just "secs"
Thus, the output should be like:
320325.566, 0.0453191 secs
I tried using sed but it's not working for some reason.
# !/bin/bash
SRC=secs\[
TRG=secs
cat GC_JAR.log | while read line
do
echo "${line}" | sed 's/"${SRC}"/"${TRG}"/g' >> GC_cycles.csv
done
Any ideas?
Page 1 of 1
SED - special characters help with SED while handling special characters
#4
Posted 02 July 2009 - 08:37 AM
personally, i'd do it this way:
I tested this on my own machine, and it worked like a dream:
Hope this helps!
cat GC_JAR.log | sed 's/secs]$/secs/g'
I tested this on my own machine, and it worked like a dream:
rhobbs@mongoose:/tmp> cat deleteme.txt 320325.566, 0.0453191 secs] 320325.566, 0.0453191 secs] 320325.566, 0.0453191 secs] 320325.566, 0.0453191 secs] 320325.566, secs] 0.0453191 secs] rhobbs@mongoose:/tmp> cat deleteme.txt | sed 's/secs]$/secs/g' 320325.566, 0.0453191 secs 320325.566, 0.0453191 secs 320325.566, 0.0453191 secs 320325.566, 0.0453191 secs 320325.566, secs] 0.0453191 secs rhobbs@mongoose:/tmp>
Hope this helps!
><> FishSponge <><
[Richard Hobbs] [HiFi Forum]
This site is funded largely out of my own pocket, so if you are feeling generous, please
[Richard Hobbs] [HiFi Forum]
This site is funded largely out of my own pocket, so if you are feeling generous, please
#5
Posted 04 July 2009 - 07:22 PM
fishsponge, on 02 July 2009 - 02:07 PM, said:
personally, i'd do it this way:
I tested this on my own machine, and it worked like a dream:
Hope this helps!
cat GC_JAR.log | sed 's/secs]$/secs/g'
I tested this on my own machine, and it worked like a dream:
rhobbs@mongoose:/tmp> cat deleteme.txt 320325.566, 0.0453191 secs] 320325.566, 0.0453191 secs] 320325.566, 0.0453191 secs] 320325.566, 0.0453191 secs] 320325.566, secs] 0.0453191 secs] rhobbs@mongoose:/tmp> cat deleteme.txt | sed 's/secs]$/secs/g' 320325.566, 0.0453191 secs 320325.566, 0.0453191 secs 320325.566, 0.0453191 secs 320325.566, 0.0453191 secs 320325.566, secs] 0.0453191 secs rhobbs@mongoose:/tmp>
Hope this helps!
Its not adviced to use cat command when you are using grep,sed or awk because they can take file as input...
so minimize the no of commands you use...
#6
Posted 06 July 2009 - 09:14 AM
good point... i should have run sed 's/secs]$/secs/g' GC_JAR.log, of course!
><> FishSponge <><
[Richard Hobbs] [HiFi Forum]
This site is funded largely out of my own pocket, so if you are feeling generous, please
[Richard Hobbs] [HiFi Forum]
This site is funded largely out of my own pocket, so if you are feeling generous, please
#7
Posted 23 July 2009 - 04:42 AM
Page 1 of 1

Sign In
Register
Help


MultiQuote
