From mboxrd@z Thu Jan 1 00:00:00 1970 From: darren kirby Subject: Re: Inserting text in a specific file in a specific point Date: Tue, 13 Dec 2005 15:17:10 -0800 Message-ID: <200512131517.14754.bulliver@badcomputer.org> References: <439F34E2.3050004@tuxdoit.com> <200512131325.07720.bulliver@badcomputer.org> <439F4943.4050107@tuxdoit.com> Reply-To: bulliver@badcomputer.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart5026289.LWUGQ88qjB"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <439F4943.4050107@tuxdoit.com> Sender: linux-admin-owner@vger.kernel.org List-Id: To: linux-admin@vger.kernel.org --nextPart5026289.LWUGQ88qjB Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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=20 print your line right after... sed -e '/PATH=3D\$PATH/a some text' .bash_profile > Warm Regards, > MARG > PS: Thank you Scott for the cool link. =2Dd > 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=3D$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=3D$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 > > - > To unsubscribe from this list: send the line "unsubscribe linux-admin" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html =2D-=20 darren kirby :: Part of the problem since 1976 :: http://badcomputer.org "...the number of UNIX installations has grown to 10, with more expected..." =2D Dennis Ritchie and Ken Thompson, June 1972 --nextPart5026289.LWUGQ88qjB Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQBDn1Z6wPD5Cr/3CJgRAqSdAJ4zpwozDWrKxFyXp3f4X+CFFtgY8ACgzp1T FXtp1tsRsRtHLGLaybR2DH8= =pOrn -----END PGP SIGNATURE----- --nextPart5026289.LWUGQ88qjB--