how to escape slashes in perl command in unix script?
Posted
by understack
on Stack Overflow
See other posts from Stack Overflow
or by understack
Published on 2010-06-11T05:48:29Z
Indexed on
2010/06/11
5:53 UTC
Read the original article
Hit count: 151
end_date=$(date +"%m/%d/%Y")
/usr/bin/perl -pi -e "s/_end_date_/${end_date}/g" filename
I want to replace string '_end_date_' with current date. Since current date has slashes in it(yes I want the slashes), I need to escape them. How can I do this?
I've tried several ways like replacing slashes with "\/" using sed and perl itself but it didn't work. Finally I used 'cut' to break date in 3 parts and escaped slashes but this solution doesn't look good. Any better solution?
© Stack Overflow or respective owner