Problem in making a script

Nils Kassube kassube at gmx.net
Sat Jul 2 09:07:15 UTC 2011


Amrit Pal Pathak wrote:
>  Till now what i have did =>user will also enter the that part of the
> line which is not needed to change in original file.
>  suppose in orignal file line 9 holds:
> 
>  device = /dev/ttyACM0
> 
>       So in scripting i have use echo command  as:
> > echo "Please enter your port address in a format => device =
> > /dev/your-port-address "
> 
>      What i think it is not right choice.He should enter only
> "ttyACM0" .Till now we are replacing the whole line .So how we can
> achieve it ?

You could extend the echo command with the rest of the text you need in 
the line. Something like this:

echo -n "Please enter device name: "
read device
...
echo "device = /dev/$device" >> "$TEMP"

However I would really suggest you learn bash scripting with the help of 
one of the manuals I mentioned in a previous mail. Or as an alternative 
I can recommend the O'Reilly book "Learning the bash shell" by 
Cameron Newham & Bill Rosenblatt. Yes, that takes time but that way you 
know what you are doing and you don't have to ask for every tiny detail 
and then hope for a useful answer.


Nils




More information about the ubuntu-users mailing list