Hi histrungalot,
This is the piece of code is not working , but when it replace the variables "$search" and "$replace" with some other text then it is working , but i want it to be more user specific so how should i specify it ???
#!/bin/tcsh -f
rm ./tmp124.txt
echo -n "Enter Search String : "
set search = $<
echo -n "Enter Replace String : "
set replace = $<
foreach line ("`cat sample.txt`")
set line = "`echo $line:gas/$search/$replace/`"
echo $line >> ./tmp124.txt
end
mv ./tmp124.txt sample.txt
unset search replace count line
You need to execute the echo command and to do that you need to use the back ticks not quotes.
#!/bin/csh
foreach line ( "`cat sample.txt`" )
# This works for me, you need the back ticks
set line = `echo "$line:gas/this/that/"`
# Now line has the new values, so check it out
echo $line
end