How to remove single quotes from a string using sed
If I need to remove the following line from certain files
ob_start('ffggg_ggg');
I have tried
grep -rl "ob_start('ffggg_ggg');" /pathtosearch | xargs sed -i 's/[ob_start('ffggg_ggg');]//g'
but the rest of the characters have been removed except for single quotes.
How can I remove single quotes from a string using sed command?
Responses
Hi Ashik,
Maybe I misunderstood your question, but this is simple way to remove what you want:
sed -i -e "s/ob_start('ffggg_ggg');//g" <myfile>
I did a quick test in a file with three lines having your string:
ob_start('ffggg_ggg'); string at beginning of line test 1
string in middle of line ob_start('ffggg_ggg'); test 2
string at end of line test 3 ob_start('ffggg_ggg');
SED command worked well.
Regards,
Dusan Baljevic (amateur radio VK2COT)
Also this...
[ me@myworkstation ~ ] # cat blah.txt
blah
#
blah
#blahblah
ob_start('ffggg_ggg');
[ me@myworkstation ~ ] # sed -i "s#ob_start('ffggg_ggg');##g" blah.txt
[ me@myworkstation ~ ] # grep ob_start blah.txt
[ me@myworkstation ~ ] # echo "in case I am misreading, another example follows"
[ me@myworkstation ~ ] # sed -i "s#'ffggg_ggg'##g" blah.txt
[ me@myworkstation ~ ] # echo "Now the last example only removes what is between the two pound (or hash) characters"
Regards,
RJ