Scenario here is I need to replace "$$file_name="
value..
I have some 150 file names in a file as mentioned below..
Eg: $$file_name=abc.bbb.ccc to_be ---> $$file_name=abc.bbb.cccV1
AS_IS :
$$a=abc.txt
$$file_name=abc.ddd.aaa
$$directory=/uasdua/asdsas
$$a=c.txt
$$file_name=ac.dd.ac
$$directory=/uasdua/asdsas
$$a=b.txt
$$file_name=ee.d.a
$$directory=/uasdua/asdsas
.
.
.
.
.
.
$$a=b.txt
$$directory=/uasdua/asdsas
$$file_name=e.d.a
to_be:
$$a=abc.txt
$$file_name=abc.ddd.aaaV1
$$directory=/uasdua/asdsas
$$a=c.txt
$$file_name=ac.dd.acV1
$$directory=/uasdua/asdsas
$$a=b.txt
$$file_name=ee.d.aV1
$$directory=/uasdua/asdsas
.
.
.
.
.
.
$$a=b.txt
$$directory=/uasdua/asdsas
$$file_name=e.d.aV1
This is what i've tried
select NAME from xxx where DATE='07/12/1999' > Name_file
#version will be same for that day
FILE_VERSION=`db2 -x "select version from xxx where DATE='07/12/1999'"` > version_name
FILE_VER=`cat version_name | head -1`
while read filename
do
FILE_NAME1=`echo ${filename}${FILE_VER}`
sed -f pattern.txt input > output
done < file_name11
pattern.txt
echo "$filename"
echo "$FILE_NAME1"
s/${filename}/${FILE_NAME1}/g ---> If I hardcode this one its not working..the value is not replaced..
s/ee.d.a/ee.d.aV1/g --> this is working
Do i need to explictly pass it..I have 150 such file names in a file ?
sed
script shell files and shell script files. Insed
-script files you cannot use variable replacement orecho
. Do not use an extra sed input file but write everything in one shell script. – jofel Jul 16 '13 at 8:54