Sunday, 15 September 2013

restricting sed command -



restricting sed command -

i have variables needs modified minutes %m added. know sed command , working expected.

# cat mysed.txt myfirstfile="comany$mydb`date +'%d-%b-%y-%h'`.sql" # sed -i 's/\%h/\%h-\%m/' mysed.txt # cat mysed.txt myfirstfile="company$mydb`date +'%d-%b-%y-%h-%m'`.sql"

but if run same sed command again, add together %m 1 time again follows.

# sed -i 's/\%h/\%h-\%m/' mysed.txt # cat mysed.txt myfirstfile="company$mydb`date +'%d-%b-%y-%h-%m-%m'`.sql"

i need sed command should add together minutes %m 1 time if sed command executed twice (by mistake)

# sed -i "s/%h'/%h-%m'/" mysed.txt

this should work. way replacement if there quote mark next %h.

sed

No comments:

Post a Comment