i want a command that interacts with the input of a user .
i.e.
i want it to serch a file for the first occurance of a variable and replace the value that is after the equal sign .
for example :
my file contains a varible that is $HOME=/home
i want to search for variable $HOME and replace the /home with some input .
things didnt work as i wanted
i have done the following
the script will prompt for the new path and then read it after that he will search the file and replace this variable ....
this is a kind of cotumization .
input="/home
while [ -z "$input" ] ; do
input=""
echo "please enter the location:\c"
read input
if [ -n "$input" ] ; then
sed '/\$HOME=/ {; s/=.*$/='"$input"'/; q; }' /file > /file.new
fi
done
NOTE : iam using ksh , Solaris 9 over sparc
input="/home
while [ -z "$input" ] ; do
input=""
echo "please enter the location:\c"
read input
if [ -n "$input" ] ; then
iFirst=$( print - 'g/^[<blank><tab>]\'$input'/n' |\
ed - file |\
sed '1 s/<tab>.$//; 2,$d' \
)
sed $iFirst' s/=.*$/='"$input"'/' file > file.new
fi
done