Inserting text in a specific file in a specific point
Inserting text in a specific file in a specific point
am 13.12.2005 21:53:54 von 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 ?
Wam Regards,
MARG
-
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
Re: Inserting text in a specific file in a specific point
am 13.12.2005 22:25:01 von darren kirby
--nextPart1289825.xB7RaateI0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
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=20
sed is the tool you need.
Try something like:
sed -e '10a\some text\' .bash_profile
> Wam Regards,
> MARG
=2Dd
=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
--nextPart1289825.xB7RaateI0
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQBDnzwzwPD5Cr/3CJgRArUaAJ9QZIQ7hHpO9rl9Y4nhT20+CgRHNwCg lxT/
WnZswcZKXxSxX3JOGmb8Mtk=
=zEdR
-----END PGP SIGNATURE-----
--nextPart1289825.xB7RaateI0--
-
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
Re: Inserting text in a specific file in a specific point
am 13.12.2005 22:40:19 von Scott Taylor
MARG said:
> Hi,
> 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 :(
It is good that you have searched the we...
What have you tried, maybe that will help us to help you.
Here is some good reading for you, it will be very helpful for you to gain
help of some more experienced admins:
http://www.catb.org/~esr/faqs/smart-questions.html
Enjoy.
--
Scott
-
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
Re: Inserting text in a specific file in a specific point
am 13.12.2005 23:20:51 von 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 ?
Warm Regards,
MARG
PS: Thank you Scott for the cool link.
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
>
-
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
Re: Inserting text in a specific file in a specific point
am 14.12.2005 00:17:10 von darren kirby
--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+CFFtgY8ACg zp1T
FXtp1tsRsRtHLGLaybR2DH8=
=pOrn
-----END PGP SIGNATURE-----
--nextPart5026289.LWUGQ88qjB--
-
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
Re: Inserting text in a specific file in a specific point
am 14.12.2005 00:17:32 von Glynn Clements
MARG wrote:
> 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".
sed -e '/^PATH=/a\some text'
--
Glynn Clements
-
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