Re: Inserting text in a specific file in a specific point

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



quoth the MARG:
> Hi Darren,
>
> Thank you for your answer.
>
> I tried that already and it works.
>
> Problem is,  it is assuming that the PATH line is line 10 and in other
> systems it may not be.
>
> Any ideas ?
>

Ok, so you will have to use sed to find the PATH line using a regex, then 
print your line right after...

sed -e '/PATH=\$PATH/a some text' .bash_profile

> Warm Regards,
> MARG
> PS: Thank you Scott for the cool link.

-d

> darren kirby wrote:
> > quoth the MARG:
> >>Hi,
> >>
> >>My .bash_profile is:
> >>----------------------
> >># .bash_profile
> >>
> >># Get the aliases and functions
> >>if [ -f ~/.bashrc ]; then
> >>	. ~/.bashrc
> >>fi
> >>
> >># User specific environment and startup programs
> >>
> >>PATH=$PATH:$HOME/bin
> >>
> >>export PATH
> >>unset USERNAME
> >>----------------------------
> >>
> >>What i'd like to do is from the command prompt or a bash script, insert
> >>text after the line "PATH=$PATH:$HOME/bin".
> >>
> >>I've searched the web and tried a few tricks, but one worked :(
> >>
> >>Could you help me please
> >
> > sed is the tool you need.
> >
> > Try something like:
> >
> > sed -e '10a\some text\' .bash_profile
> >
> >>Wam Regards,
> >>MARG
> >
> > -d
>
> -
> : send the line "unsubscribe linux-admin" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
darren kirby :: Part of the problem since 1976 :: http://badcomputer.org
"...the number of UNIX installations has grown to 10, with more expected..."
- Dennis Ritchie and Ken Thompson, June 1972

Attachment: pgpzJSqAPZ1FJ.pgp
Description: PGP signature


[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux