Re: sed "Hello, world!" program?

<[email protected]>
Newsgroups gmane.editors.sed.user
Message-ID <[email protected]>
Zharif,
 

 ------------------
s/.*/Hello, world!/
q
------------------
 

 shows sed script in a file, called with sed -f option, as Tim pointed out. The script can go on the command line, in the ways that you listed. Anyway, the command line script doesn't work well for the special "Hello, world!" example, mainly because C shell interprets the exclamation character on the command line, as Rakesh pointed out.
 

 /////////////////
 

 Related to sed ...<<<"hello world" proposal from Thierry - I think inconsistencies between different environments will occur, so it will not work. For example, just trying a few (not even looking at cmd.exe):
 

 ---------------------------------
bash$ sed "" <<< "Hello, world!"
-bash: !": event not found
bash$ sed "" <<< 'Hello, world!'
Hello, world!
csh%  sed "" <<< 'Hello, world!'
Missing name for redirect.
---------------------------------
 

 Even if sed ...<<<"hello world" worked perfectly everywhere, I don't think it would be a good "Hello, world!" example. It says nothing about sed, is really a statement about the shell, since you could substitute cat
for sed and have the same effect. A good "Hello, world!" example has to show something about the language.
 

 Any more thoughts? If I don't hear back in a week or so, I will try putting into the wikipedia list:
 

 ------------------------------
# convert input text stream to "Hello, world!"
s/.*/Hello, world!/
q
------------------------------
 

 Daniel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.