linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: darren kirby <bulliver@badcomputer.org>
To: linux-admin@vger.kernel.org
Subject: Re: Inserting text in a specific file in a specific point
Date: Tue, 13 Dec 2005 15:17:10 -0800	[thread overview]
Message-ID: <200512131517.14754.bulliver@badcomputer.org> (raw)
In-Reply-To: <439F4943.4050107@tuxdoit.com>

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

  reply	other threads:[~2005-12-13 23:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2005-12-13 21:40 ` Scott Taylor
2005-12-13 23:17 ` Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200512131517.14754.bulliver@badcomputer.org \
    --to=bulliver@badcomputer.org \
    --cc=linux-admin@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).