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
#2
Posted 07 April 2009 - 08:27 AM
Use of ' won't allow your variable to be expanded.
Use " instead and you can get rid of the inner ones.
Use " instead and you can get rid of the inner ones.
Vibhor Kumar Agarwal
#3
Posted 01 July 2009 - 11:16 PM
whay that much scrpting req for that
use simple tr
use simple tr
tr '\]' ' ' <filename
sed 's/\]//g' filename
awk '/\]/{gsub("\]"," ")}{print}' filename
#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
Share this topic:
Page 1 of 1

Help












