Hello world/Standard error: Difference between revisions

Content added Content deleted
(added powerbasic)
(→‎{{header|AWK}}: Add my /dev/stderr example again, with new text to explain that /dev/stderr might not work. "cat 1>&2" is better.)
Line 48: Line 48:


=={{header|AWK}}==
=={{header|AWK}}==
Pipe through a shell command:

<lang awk>BEGIN {
<lang awk>BEGIN {
print "Goodbye, World!"| "cat 1>&2"
print "Goodbye, World!"| "cat 1>&2"
}</lang>
}</lang>

Or write to /dev/stderr:

{{works with|gawk}}
{{works with|mawk}}
<lang awk>BEGIN {
print "Goodbye, World!" > "/dev/stderr"
}</lang>

As their manuals explain, [[gawk]] and [[mawk]] associate "/dev/stderr" with standard error. Other implementations, like [[nawk]], try to open /dev/stderr as a file. [[BSD]] (and perhaps some other Unix clones) have a /dev/stderr device node that duplicates standard error, so this code would still work. We recommend "cat 1>&2", which is more portable. Some systems have no /dev/stderr device node, but all Unix clones have a Bourne-compatible shell and a cat command.


=={{header|Batch File}}==
=={{header|Batch File}}==