0

Script abc.ksh should replace value of file xyz.sql as below

Search for string "%s_sitename as of date "+%Y-%b-%e"" where date changed with sysdate everytime we execute abc.ksh

s1='%s_sitename%[a-z][0-9]/-'
s2='%s_sitename%'"$(date "+%Y-%b-%e")"
sed -i 's/'"$s1"'/'"$s2"'/g' xyz.sql       

abc.sql file should be updated every time with sysdate as below

"%s_sitename% as of 2016-Jun-22"

With current come I am getting wired output as below

Community
  • 1
  • 1
S.Modi
  • 15
  • 4

1 Answers1

0
s1='%s_sitename% as of [a-zA-Z0-9-]*'
s2='%s_sitename% as of '"$(date "+%Y-%b-%e")"
sed -i 's/'"$s1"'/'"$s2"'/g' xyz.sql

Test:

echo "%s_sitename% as of 2005-Apr-02" | sed 's/'"$s1"'/'"$s2"'/g'

Output:

%s_sitename% as of 2016-Jun-26

See: The Stack Overflow Regular Expressions FAQ

Community
  • 1
  • 1
Cyrus
  • 69,405
  • 13
  • 65
  • 117