Re: Insert a line in a textfile from a script
From: Laurent Vogel (lvl_at_club-internet.fr)
Date: 05/01/03
- Previous message: Laurent Vogel: "Re: Script to checking a file existence then send an email to myself."
- Maybe in reply to: Hyo Joon You: "Re: Insert a line in a textfile from a script"
- Next in thread: Micke: "Re: Insert a line in a textfile from a script"
- Reply: Micke: "Re: Insert a line in a textfile from a script"
- Reply: Hyo Joon You: "Re: Insert a line in a textfile from a script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 1 May 2003 00:17:19 +0200
Micke wrote:
> I want to insert a new line in a textfile from a script.
you could try using head and tail if your line is to be inserted in
a fixed line number.
For any non trivial case I would use sed (despite what Hyo Joon You
says, ed is outdated, slow for big files, and there are platforms
where it is not installed by default anymore).
the idea is either:
1) to build a file containing:
/PATTERN/a\
your edited line to be appended
and doing sed -f THIS_FILE_JUST_BUILT
(problem: the line needs to be edited to replace \ by \\)
2) else, put the line infile FOO and do
sed -e '/PATTERN/rfoo'
If this doesn't suffice please give more details about your specific
problem.
Laurent
- Previous message: Laurent Vogel: "Re: Script to checking a file existence then send an email to myself."
- Maybe in reply to: Hyo Joon You: "Re: Insert a line in a textfile from a script"
- Next in thread: Micke: "Re: Insert a line in a textfile from a script"
- Reply: Micke: "Re: Insert a line in a textfile from a script"
- Reply: Hyo Joon You: "Re: Insert a line in a textfile from a script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|