Hi pokerino,
Thanks. the code is working but i didt run the script separately i.e ./newfile.sh sec.txt disp.out . If i run in that way it is working. I am using this code as part of the script. That is this code comes in one part of big script file. Then in that case how can i run the file with parameter in run time. I want to use those parameter files inside the code or inside the main script file. help me out.
Thank you it works fine. One more thing,
I have a text file as 1.txt with following content,
q34566788u
w2343556666t
I have used script file sample.sh with content,
#!/bin/ksh
echo "Enter the Value : "
read value
echo "$value"
sed '1s:\(.\{4\}\)\(.\{3\}\):\1$value:' 1.txt
I used the script file to replace the value 6678 in 1.txt file with the input value on run time which i try to read with variable name value. But its not replacing the value stored on variable instead its replacing $value i.e o/p
q345$value8u
.
I want the output as
q345(input value)8u
with input value on runtime in dash places.
Help me out.
---------- Post updated at 10:37 AM ---------- Previous update was at 10:34 AM ----------
I got the result,
I $value in sed command inside '$value ' it works.
#!/bin/ksh
mv /int/int1/abc.txt /int/int1/1.txt
echo "Enter the Value : " read value echo "$value" sed '1s:\(.\{4\}\)\(.\{3\}\):\1'$value':' 1.txt
In the above code i try to replace the value in 1.txt file
But its not working. When i use someother file already created in that path, its working.
but when i created the file at run time as in above code its not working.
when i used the file 1.txt its replacing the string and not reading the input value.