All of lore.kernel.org
 help / color / mirror / Atom feed
* Inserting text in a specific file in a specific point
@ 2005-12-13 20:53 MARG
  2005-12-13 21:25 ` darren kirby
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: MARG @ 2005-12-13 20:53 UTC (permalink / raw)
  To: linux-admin

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Inserting text in a specific file in a specific point
  2005-12-13 20:53 Inserting text in a specific file in a specific point MARG
@ 2005-12-13 21:25 ` darren kirby
  2005-12-13 22:20   ` MARG
  2005-12-13 21:40 ` Scott Taylor
  2005-12-13 23:17 ` Glynn Clements
  2 siblings, 1 reply; 6+ messages in thread
From: darren kirby @ 2005-12-13 21:25 UTC (permalink / raw)
  To: linux-admin

[-- Attachment #1: Type: text/plain, Size: 892 bytes --]

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

-- 
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 #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Inserting text in a specific file in a specific point
  2005-12-13 20:53 Inserting text in a specific file in a specific point MARG
  2005-12-13 21:25 ` darren kirby
@ 2005-12-13 21:40 ` Scott Taylor
  2005-12-13 23:17 ` Glynn Clements
  2 siblings, 0 replies; 6+ messages in thread
From: Scott Taylor @ 2005-12-13 21:40 UTC (permalink / raw)
  To: MARG; +Cc: linux-admin


MARG said:
> Hi,
<sweep>
> 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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Inserting text in a specific file in a specific point
  2005-12-13 21:25 ` darren kirby
@ 2005-12-13 22:20   ` MARG
  2005-12-13 23:17     ` darren kirby
  0 siblings, 1 reply; 6+ messages in thread
From: MARG @ 2005-12-13 22:20 UTC (permalink / raw)
  To: linux-admin, bulliver

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
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Inserting text in a specific file in a specific point
  2005-12-13 22:20   ` MARG
@ 2005-12-13 23:17     ` darren kirby
  0 siblings, 0 replies; 6+ messages in thread
From: darren kirby @ 2005-12-13 23:17 UTC (permalink / raw)
  To: linux-admin

[-- Attachment #1: Type: text/plain, Size: 1687 bytes --]

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
>
> -
> 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

-- 
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 #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Inserting text in a specific file in a specific point
  2005-12-13 20:53 Inserting text in a specific file in a specific point MARG
  2005-12-13 21:25 ` darren kirby
  2005-12-13 21:40 ` Scott Taylor
@ 2005-12-13 23:17 ` Glynn Clements
  2 siblings, 0 replies; 6+ messages in thread
From: Glynn Clements @ 2005-12-13 23:17 UTC (permalink / raw)
  To: MARG; +Cc: linux-admin


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 <glynn@gclements.plus.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-12-13 23:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-13 20:53 Inserting text in a specific file in a specific point MARG
2005-12-13 21:25 ` darren kirby
2005-12-13 22:20   ` MARG
2005-12-13 23:17     ` darren kirby
2005-12-13 21:40 ` Scott Taylor
2005-12-13 23:17 ` Glynn Clements

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.