Re: is there a replace command ?
# [EMAIL PROTECTED] / 2002-12-03 11:13:39 +0100: On Tue, 3 Dec 2002, Malik Blent wrote: But my expression has / that is there is a / in a expression What shall i do ? my expression is new: 11 I want to change new: 11 with new/11 thanks # echo new: 11 | sed s/new\:\ 11/new\\/11/ you don't have to use slashes for the delimiters. see sed(1). roman@freepuppy ~ 1003:0 echo new: 11 | sed 's,: ,/,' new/11 roman@freepuppy ~ 1004:0 echo new: 11 | sed 's:\: :/:' new/11 roman@freepuppy ~ 1005:0 echo new: 11 | sed 's-: -/-' new/11 -- If you cc me or remove the list(s) completely I'll most likely ignore your message.see http://www.eyrie.org./~eagle/faqs/questions.html To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
On Tue, 3 Dec 2002, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2002-12-03 11:13:39 +0100: On Tue, 3 Dec 2002, Malik Bülent wrote: But my expression has / that is there is a / in a expression What shall i do ? my expression is new: 11 I want to change new: 11 with new/11 thanks # echo new: 11 | sed s/new\:\ 11/new\\/11/ you don't have to use slashes for the delimiters. see sed(1). roman@freepuppy ~ 1003:0 echo new: 11 | sed 's,: ,/,' new/11 roman@freepuppy ~ 1004:0 echo new: 11 | sed 's:\: :/:' new/11 roman@freepuppy ~ 1005:0 echo new: 11 | sed 's-: -/-' new/11 Thanks for the tip! I wasn't aware of that. When it comes to man sed(1): Reading a Kafka book is light weight reading compared to that man page. :-) Best regards, Paul To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
On Tue, Dec 03, 2002 at 11:42:05AM +0100, Paul Everlund wrote: On Tue, 3 Dec 2002, Roman Neuhauser wrote: # [EMAIL PROTECTED] / 2002-12-03 11:13:39 +0100: On Tue, 3 Dec 2002, Malik Blent wrote: But my expression has / that is there is a / in a expression What shall i do ? my expression is new: 11 I want to change new: 11 with new/11 thanks # echo new: 11 | sed s/new\:\ 11/new\\/11/ you don't have to use slashes for the delimiters. see sed(1). roman@freepuppy ~ 1003:0 echo new: 11 | sed 's,: ,/,' new/11 roman@freepuppy ~ 1004:0 echo new: 11 | sed 's:\: :/:' new/11 roman@freepuppy ~ 1005:0 echo new: 11 | sed 's-: -/-' new/11 Thanks for the tip! I wasn't aware of that. When it comes to man sed(1): Reading a Kafka book is light weight reading compared to that man page. :-) Mmm, it ought to be in lights. Problem with sed is that it has a set of advanced features that very few people ever work out how to use. Simple facts like the possibility of using another string delimiter probably get lost in the melee. The advanced features could probably be wripped out and I doubt if anyone would notice... -- Regards Cliff Sarginson The Netherlands [ This mail has been checked as virus-free ] To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
is there a replace command ?
On Freebsd4.x I have a file. I want to change some expressions with new ones For example a file touch /var/qmail/1 touch /var/qmail/2 touch /var/qmail/3 touch /var/qmail/4 touch /var/qmail/5 touch /var/qmail/6 I want to change touch with rm How can i replace a newones in stead of a lot of expressions in a file on FreeBSD ? Which command(s) do i have to use ? To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
On Mon, 2 Dec 2002, [iso-8859-9] Malik Bülent wrote: On Freebsd4.x I have a file. I want to change some expressions with new ones For example a file touch /var/qmail/1 touch /var/qmail/2 touch /var/qmail/3 touch /var/qmail/4 touch /var/qmail/5 touch /var/qmail/6 I want to change touch with rm How can i replace a newones in stead of a lot of expressions in a file on FreeBSD ? Which command(s) do i have to use ? man sed(1) # cat file | sed s/touch/rm/ file.tmp Best regards, Paul To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
Today Malik Bülent wrote: On Freebsd4.x I have a file. I want to change some expressions with new ones For example a file touch /var/qmail/1 touch /var/qmail/2 touch /var/qmail/3 touch /var/qmail/4 touch /var/qmail/5 touch /var/qmail/6 I want to change touch with rm How can i replace a newones in stead of a lot of expressions in a file on FreeBSD ? Which command(s) do i have to use ? 1) sed -e 's,^touch,rm,g' infile outfile 2) while read a b; do echo rm $b; done infile outfile 3) awk '{print rm $2}' infile outfile -andrew To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
On 02-Dec-2002 Malik Bülent wrote: On Freebsd4.x I have a file. I want to change some expressions with new ones For example a file touch /var/qmail/1 touch /var/qmail/2 touch /var/qmail/3 touch /var/qmail/4 touch /var/qmail/5 touch /var/qmail/6 I want to change touch with rm How can i replace a newones in stead of a lot of expressions in a file on FreeBSD ? Which command(s) do i have to use ? Recent versions of FreeBSD now have a version of 'sed' that can do these types of replacements in place, i.e., without the need for a temporary file: sed -i -e 's/^touch /rm /' infile That were a easy one. :-) -- Conrad Sabatier [EMAIL PROTECTED] To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
sed -e 's/touch/rm/' FILENAME OUTPUT_FILE or something like, perl -pi -e 's/touch/rm/;' FILENAME man 1 sed for a lot more detail - Original Message - From: Malik Blent [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, December 02, 2002 7:18 AM Subject: is there a replace command ? On Freebsd4.x I have a file. I want to change some expressions with new ones For example a file touch /var/qmail/1 touch /var/qmail/2 touch /var/qmail/3 touch /var/qmail/4 touch /var/qmail/5 touch /var/qmail/6 I want to change touch with rm How can i replace a newones in stead of a lot of expressions in a file on FreeBSD ? Which command(s) do i have to use ? To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
Today Conrad Sabatier wrote: On 02-Dec-2002 Malik Bülent wrote: On Freebsd4.x I have a file. I want to change some expressions with new ones For example a file touch /var/qmail/1 touch /var/qmail/2 touch /var/qmail/3 touch /var/qmail/4 touch /var/qmail/5 touch /var/qmail/6 I want to change touch with rm How can i replace a newones in stead of a lot of expressions in a file on FreeBSD ? Which command(s) do i have to use ? Recent versions of FreeBSD now have a version of 'sed' that can do these types of replacements in place, i.e., without the need for a temporary file: No. I'm pretty sure, there is a temporary file somewhere. You can't edit a file `in place' really, w/o a need temporary files (or ev. memory mapping the file). With the `-i' flag sed does this for you, ie. no need that you create a temporary file. -andrew sed -i -e 's/^touch /rm /' infile To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
# [EMAIL PROTECTED] / 2002-12-02 14:20:44 +0100: Today Conrad Sabatier wrote: Recent versions of FreeBSD now have a version of 'sed' that can do these types of replacements in place, i.e., without the need for a temporary file: sed -i -e 's/^touch /rm /' infile No. I'm pretty sure, there is a temporary file somewhere. You can't edit a file `in place' really, w/o a need temporary files (or ev. memory mapping the file). With the `-i' flag sed does this for you, ie. no need that you create a temporary file. wow, even the man page is not this anal. :) point in case: there's no tmp file from the user's perspective, and Conrad Sabatier's description is in line with the man page text: -i extension Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved. It is not recommended to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situ ations where disk space is exhausted, etc. -- If you cc me or remove the list(s) completely I'll most likely ignore your message.see http://www.eyrie.org./~eagle/faqs/questions.html To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
On Mon, 2 Dec 2002, [iso-8859-9] Malik Bülent wrote: On Freebsd4.x I have a file. I want to change some expressions with new ones For example a file touch /var/qmail/1 touch /var/qmail/2 touch /var/qmail/3 touch /var/qmail/4 touch /var/qmail/5 touch /var/qmail/6 I want to change touch with rm How can i replace a newones in stead of a lot of expressions in a file on FreeBSD ? Which command(s) do i have to use ? Unfortunately I deleted your other mail, asking how to remove lines containing some text in a file, but this might be one of many solutions: # perl -e 'open(FD,file); while(FD) { if(!($_ =~ /texttolookfor/)) { print $_; }} close(FD);' file.tmp This has not been tested, so use it at your own risk. :-) Best regards, Paul To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
# [EMAIL PROTECTED] / 2002-12-02 16:36:21 +0100: On Mon, 2 Dec 2002, [iso-8859-9] Malik Blent wrote: On Freebsd4.x I have a file. I want to change some expressions with new ones For example a file touch /var/qmail/1 touch /var/qmail/2 touch /var/qmail/3 touch /var/qmail/4 touch /var/qmail/5 touch /var/qmail/6 I want to change touch with rm How can i replace a newones in stead of a lot of expressions in a file on FreeBSD ? Which command(s) do i have to use ? Unfortunately I deleted your other mail, asking how to remove lines containing some text in a file, but this might be one of many solutions: # perl -e 'open(FD,file); while(FD) { if(!($_ =~ /texttolookfor/)) { print $_; }} close(FD);' file.tmp This has not been tested, so use it at your own risk. :-) how about this? even tested :) sed -i'' '/pattern/d' file -- If you cc me or remove the list(s) completely I'll most likely ignore your message.see http://www.eyrie.org./~eagle/faqs/questions.html To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message
Re: is there a replace command ?
# [EMAIL PROTECTED] / 2002-12-02 16:53:01 +0100: # [EMAIL PROTECTED] / 2002-12-02 16:36:21 +0100: On Mon, 2 Dec 2002, [iso-8859-9] Malik Blent wrote: On Freebsd4.x I have a file. I want to change some expressions with new ones For example a file touch /var/qmail/1 touch /var/qmail/2 touch /var/qmail/3 touch /var/qmail/4 touch /var/qmail/5 touch /var/qmail/6 I want to change touch with rm How can i replace a newones in stead of a lot of expressions in a file on FreeBSD ? Which command(s) do i have to use ? Unfortunately I deleted your other mail, asking how to remove lines containing some text in a file, but this might be one of many solutions: # perl -e 'open(FD,file); while(FD) { if(!($_ =~ /texttolookfor/)) { print $_; }} close(FD);' file.tmp This has not been tested, so use it at your own risk. :-) how about this? even tested :) sed -i'' '/pattern/d' file gee, there must be whitespace betwwen -i and '' for this to work... -- If you cc me or remove the list(s) completely I'll most likely ignore your message.see http://www.eyrie.org./~eagle/faqs/questions.html To Unsubscribe: send mail to [EMAIL PROTECTED] with unsubscribe freebsd-questions in the body of the message