Problem in making a script

Amrit Pal Pathak amritpalpathak1 at
Sat Jul 2 06:45:35 UTC 2011

On Thu, Jun 30, 2011 at 6:51 AM, Nils Kassube <kassube at> wrote:

> amritpal pathak wrote:
> > On Thu, Jun 30, 2011 at 4:37 AM, Nils Kassube <kassube at> wrote:
> > > > TEMP=$(mktemp)
> > >
> > > Make a temporary file which doesn't conflict with existing files.
> > >
> >      means temporary file with same name as original?
> No, it is a file in /tmp created by mktemp with an arbitrary filename
> that did not yet exist. The filename is stored in the variable TEMP. We
> don't care about the actual file name because we handle everything with
> the variable instead. At the end the temp file is moved to the original
> file name anyway.

     OK .Thanks for explanation.I got it.
    Sir can we make it more easier.?
 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 ?

Code is :

echo "Please enter your port address in a format => device =
/dev/your-port-address "
read fname
head -n $((29 - 1)) "kannel.conf" > "$TEMP"
echo "$fname" >> "$TEMP"
LEN=$(cat "kannel.conf"|wc -l)
tail -n $(($LEN - 29)) "kannel.conf" >> "$TEMP"
mv  "$TEMP" "kannel.conf"

Thanks again !!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ubuntu-users mailing list