Prev: Which Program can reformat and indent ksh or sh shell script
Next: Want to insert some stuff as a new line after the line matchingregexp.
From: Sidney Lambe on 22 Mar 2010 15:27 On comp.unix.shell, Stephane CHAZELAS <stephane_chazelas(a)yahoo.fr> wrote: > [delete] > printf 'foobar\none\ntwo\n' > > is POSIX and Unix, and is the POSIX recommended alternative to > the non-portable echo command. > Why do you call echo 'non-portable'? I've never heard of a linux/unix operating system that didn't have it. It's even on every embedded linux/unix OS I've come across and on all the rescue disks and one and two floppy OS's. > echo 'foobar\none\ntwo' > > would work on Unix systems. It's echo -e on Linux. Sid
From: Seebs on 22 Mar 2010 15:56 On 2010-03-22, Sidney Lambe <sidneylambe(a)nospam.invalid> wrote: > On comp.unix.shell, Stephane CHAZELAS <stephane_chazelas(a)yahoo.fr> wrote: >> is POSIX and Unix, and is the POSIX recommended alternative to >> the non-portable echo command. > Why do you call echo 'non-portable'? I've never heard of a > linux/unix operating system that didn't have it. Probably not "echo", but "the specific usage of echo shown". The usage of embedded escape sequences isn't portable, nor is -n, nor is \c... If you want anything but plain text unaltered followed by a newline, use printf. (Which is surprisingly portable, except for very small embedded systems.) -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
From: Ivan Shmakov on 23 Mar 2010 08:37 >>>>> Seebs <usenet-nospam(a)seebs.net> writes: >>>>> Sidney Lambe <sidneylambe(a)nospam.invalid> wrote: >>>>> Stephane CHAZELAS <stephane_chazelas(a)yahoo.fr> wrote: >>> is POSIX and Unix, and is the POSIX recommended alternative to >>> the non-portable echo command. >> Why do you call echo 'non-portable'? I've never heard of a >> linux/unix operating system that didn't have it. > Probably not "echo", but "the specific usage of echo shown". > The usage of embedded escape sequences isn't portable, nor is -n, nor > is \c... If you want anything but plain text unaltered followed by a > newline, use printf. (Which is surprisingly portable, except for > very small embedded systems.) And, actually, echo(1) cannot be relied upon for unaltered plain text output as well. Consider, e. g.: $ (a=-e ; echo "$a") $ (a=-n ; echo "$a") $ On some systems, the output of the first may be '-e' and (or) the output of the second may be '-n'. -- FSF associate member #7257
From: Seebs on 23 Mar 2010 13:11
On 2010-03-23, Ivan Shmakov <ivan(a)main.uusia.org> wrote: > And, actually, echo(1) cannot be relied upon for unaltered plain > text output as well. Consider, e. g.: D'oh! I forgot about that. -s -- Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nospam(a)seebs.net http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated! |