[net.unix] echo command always prints its arguments

sdo@u1100a.UUCP (Scott Orshan) (04/02/85)

On every UNIX system I have ever used, there is no way to prevent
the echo command from printing its arguments.  I would like to
propose a "-q" option to echo which tells it to be quiet and go about
its work without printing its arguments.
-- 

			Scott Orshan
			Bell Communications Research
			201-981-3064
			{ihnp4,allegra,bellcore,pyuxww}!u1100a!sdo

ark@alice.UUCP (Andrew Koenig) (04/02/85)

> On every UNIX system I have ever used, there is no way to prevent
> the echo command from printing its arguments.  I would like to
> propose a "-q" option to echo which tells it to be quiet and go about
> its work without printing its arguments.
> -- 
>
>			Scott Orshan
> 			Bell Communications Research
>			201-981-3064
>			{ihnp4,allegra,bellcore,pyuxww}!u1100a!sdo
>

This option is unnecessary because you can obtain the
equivalent effect by redirecting the standard output:

	echo $args >/dev/null

Doing it this way has the advantage of greater portability, too.

veach@ihuxl.UUCP (Michael T. Veach) (04/02/85)

> On every UNIX system I have ever used, there is no way to prevent
> the echo command from printing its arguments.  I would like to
> propose a "-q" option to echo which tells it to be quiet and go about
> its work without printing its arguments.
> -- 
> 
> 			Scott Orshan
> 			Bell Communications Research
> 			201-981-3064
> 			{ihnp4,allegra,bellcore,pyuxww}!u1100a!sdo


What other work does echo have besides printing its arguments?


-- 

	Michael T. Veach
	  ihuxl!veach

henry@utzoo.UUCP (Henry Spencer) (04/03/85)

> ...  I would like to
> propose a "-q" option to echo which tells it to be quiet and go about
> its work without printing its arguments.

Shush!  Don't say that where Berkeley or AT&T can hear you, or they'll
do it for the next release!

"/dev/null ?  Never heard of it.  Gotta have a -q option."
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry

steve@tellab3.UUCP (Steve Harpster) (04/03/85)

Shouldn't this be in net.jokes?  If echo didn't print its arguments,
what good would it be?!?  I mean, what else does your version do?
Can you give me an example of how you would use your `-q' option?
-- 


...ihnp4!tellab1!steve
Steve Harpster
Tellabs, Inc.

sdo@u1100a.UUCP (Scott Orshan) (04/03/85)

In article <797@u1100a.UUCP> I wrote:
>On every UNIX system I have ever used, there is no way to prevent
>the echo command from printing its arguments.  I would like to
>propose a "-q" option to echo which tells it to be quiet and go about
>its work without printing its arguments.
>-- 
>
>			Scott Orshan

OK.  I've gotten enough replies.  April Fool.  Most people
realized this and answered in the spirit of the day.  However,
I don't blame those who took it seriously - it resembles many
of the legitimate articles posted here.  It's also a take-off
on "cat -v"

Most of the answers said to use "echo arg ... >/dev/null"

A better answer (since it doesn't involve opening /dev/null)
was "echo '\c' arg ..." (In the USG echo, \c is used as "-n" is
used in BSD).

-- 

			Scott Orshan
			Bell Communications Research
			201-981-3064
			{ihnp4,allegra,bellcore,pyuxww}!u1100a!sdo

jdb@hou5f.UUCP (John Bell) (04/03/85)

Excuse me for being confused, but I thought that echo was SUPPOSED to
print its arguments.  If you mean to put its args into another place,
use shell I/O redirection:
	"echo foo bar baz >some.other.file"
Of course, that file could be "/dev/null" if you really want to discard
the results (???)
-- 
~~~~~~~~~~~~~~~~~~~~
    John D. Bell,  AT&T-ISL		Holmdel, NJ   1J317   (201) 834-3372
				 UUCP:  ...{ihnp4,hou??,ucbvax}!hou5f!jdb
"...You may be right, I may be crazy,
    but it just may be a lunatic you're looking for..."		-Billy Joel

schnable@ihuxo.UUCP (Andrew T. Schnable) (04/03/85)

> On every UNIX system I have ever used, there is no way to prevent
> the echo command from printing its arguments.  I would like to
> propose a "-q" option to echo which tells it to be quiet and go about
> its work without printing its arguments.
> -- 
> 
> 			Scott Orshan
> 			Bell Communications Research
> 			201-981-3064
> 			{ihnp4,allegra,bellcore,pyuxww}!u1100a!sdo

Great idea. Maybe cat(1) needs this argument too.  Heck, 
If we add it to everything, we may be able to do away with /dev/null!

andy ihuxo!schnable

dan@rna.UUCP (Dan Ts'o) (04/03/85)

In article <> veach@ihuxl.UUCP (Michael T. Veach) writes:
>What other work does echo have besides printing its arguments?

Well, lots

	By studying the differential CPU usage between "echo" and "echo hello"
one can deduce the CPU time required for the shell to set up arguments. A -q
option would facilitate this study.
	It is an idea command name with which to practice touch typing.
	It is a command which is easy to learn.
	It exercises the disk.
	It is a firm base for an April 1 ruse.

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (04/06/85)

> On every UNIX system I have ever used, there is no way to prevent
> the echo command from printing its arguments.  I would like to
> propose a "-q" option to echo which tells it to be quiet and go about
> its work without printing its arguments.

Are you serious?

david@ukma.UUCP (David Herron, NPR Lover) (04/06/85)

>Shouldn't this be in net.jokes?  If echo didn't print its arguments,
>what good would it be?!?  I mean, what else does your version do?
>Can you give me an example of how you would use your `-q' option?

Ok....

	echo -q This creates an empty file >new.file

Since, with csh, there is no longer an easy way to create an empty
file.  (With sh one could type just ">new.file").

-- 
--- David Herron
--- ARPA-> ukma!david<@ANL-MCS> or david%ukma.uucp@anl-mcs.arpa
---        Or even anlams!ukma!david@ucbvax.arpa
--- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david
---        cbosgd!ukma!david

	"The home of poly-unsaturated thinking".

ken@rochester.UUCP (Ken Yap) (04/07/85)

In article <1581@ukma.UUCP> david@ukma.UUCP (David Herron, NPR Lover) writes:
>	echo -q This creates an empty file >new.file
>
>Since, with csh, there is no longer an easy way to create an empty
>file.  (With sh one could type just ">new.file").

	cp /dev/null new.file

works with either shell. :-)

	Ken
-- 
UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
USnail:	Dept. of Comp. Sci., U. of Rochester, NY 14627. Voice: Ken!

roy@phri.UUCP (Roy Smith) (04/08/85)

> Since, with csh, there is no longer an easy way to create an empty

Uh, how about "cp /dev/null new-empty-file"?
-- 

cmcl2!rocky2!cubsvax -\
       vax135!timeinc -> !phri!roy (Roy Smith, System Administrator)
             allegra -/

The opinions expressed herein do not necessarily reflect
the views of the Public Health Research Institute.

hopp@nbs-amrf.UUCP (Ted Hopp) (04/09/85)

> > Can you give me an example of how you would use your `-q' option?
> 
> 	echo -q This creates an empty file >new.file
> 
> Since, with csh, there is no longer an easy way to create an empty
> file.  (With sh one could type just ">new.file").
> 
> --- David Herron

But "echo > new.file" works just fine with our csh.  (Eunice 3.2;
a.k.a. ersatz BSD 4.1).
-- 

Ted Hopp	{seismo,umcp-cs}!nbs-amrf!hopp

ronbe@tekred.UUCP (Little Guy) (04/09/85)

-> >	echo -q This creates an empty file >new.file
-> >
-> >Since, with csh, there is no longer an easy way to create an empty
-> >file.  (With sh one could type just ">new.file").
-> 
-> 	cp /dev/null new.file
-> 
-> works with either shell. :-)
-> 
-> 	Ken

What's wrong with echo -n "" > new.file   ???
-- 
Support bacteria - It's the only culture some people have!
	...tektronix!tekred!ronbe (Ron Bemis)

jordan@ucbvax.ARPA (Jordan Hayes) (04/10/85)

>>Shouldn't this be in net.jokes?  If echo didn't print its arguments,
>>what good would it be?!?  I mean, what else does your version do?
>>Can you give me an example of how you would use your `-q' option?

>Ok....
>
>	echo -q This creates an empty file >new.file
>
>Since, with csh, there is no longer an easy way to create an empty
>file.  (With sh one could type just ">new.file").
>
>-- 
>--- David Herron

Come on... "echo > new.file" or "cat > new.file" with a ^D directly on the
next line works fine... some people just can't take a joke....

/jordan
-------
ARPA:	jordan@berkeley.ARPA
UUCP:	..!ucbvax!jordan

phil@amdcad.UUCP (Phil Ngai) (04/10/85)

> -> >Since, with csh, there is no longer an easy way to create an empty
> -> >file.  (With sh one could type just ">new.file").

How about:

touch new.file
-- 
 Preverted word of the day: tribadism, to rub

 Phil Ngai (408) 749-5720
 UUCP: {ucbvax,decwrl,ihnp4,allegra}!amdcad!phil
 ARPA: amdcad!phil@decwrl.ARPA

edhall@randvax.UUCP (Ed Hall) (04/10/85)

> > Since, with csh, there is no longer an easy way to create an empty

Since csh's built-in echo command doesn't output a newline unless it has
at least one argument, the following creates an empty file quite well:

	echo >empty.file

Of course, this means you ahve to give echo a null argument, at least,
if you really *wanted* a newline.

Yet another case of csh trying to be more ``useful'' by adding yet
another piddling feature.

		-Ed Hall
		decvax!randvax!edhall

uddeborg@chalmers.UUCP (G|ran Uddeborg) (04/11/85)

In article <1581@ukma.UUCP> david@ukma.UUCP (David Herron, NPR Lover) writes:
	.
	.
	.
>	echo -q This creates an empty file >new.file
>
>Since, with csh, there is no longer an easy way to create an empty
>file.  (With sh one could type just ">new.file").

Well, what about

	touch new.file

or

	echo >new.file

or

	eval >new.file

or

	true >new.file

Do you wish more examples? :-)

(Yes, I know the first example behaves differently if the file already
exists.)
-- 
"For me, UNIX is a (way of) being."

	G|ran Uddeborg
	UUCP:	{seismo,philabs,decvax}!mcvax!enea!chalmers!uddeborg
	CSnet: 	uddeborg@chalmers.csnet

dave@circadia.UUCP (David Messer) (04/11/85)

> On every UNIX system I have ever used, there is no way to prevent
> the echo command from printing its arguments.  I would like to
> propose a "-q" option to echo which tells it to be quiet and go about
> its work without printing its arguments.

Yes, this IS a major flaw in UNIX.  I have often wanted to do this.
Here is a shell script that I use and hope that you can also use:

------CUT------CUT------CUT------CUT------
#!sh
for i in $*
do
	case $i in
		-q)	exit ;;
	esac
done
echo $*
#:-)

-- 

Dave Messer   ...ihnp4!stolaf!umn-cs!circadia!dave

mbk@denning.uucp (Mark B. Kadonoff) (04/13/85)

	The easiest way I know of is 'touch new.file'.

-- 

		Mark Kadonoff 
		Denning Mobile Robotics, Inc. 
		(617) 935-4840
		UUCP:  ..!decvax!linus!security!denning!mbk
		ARPA:  denning!mbk@CMU-RI-ROVER

rwl@uvacs.UUCP (Ray Lubinsky) (04/13/85)

> >Shouldn't this be in net.jokes?  If echo didn't print its arguments,
> >what good would it be?!?  I mean, what else does your version do?
> >Can you give me an example of how you would use your `-q' option?
> 
> Ok....
> 
> 	echo -q This creates an empty file >new.file
> 
> Since, with csh, there is no longer an easy way to create an empty
> file.  (With sh one could type just ">new.file").
> 
---

A few people have mentioned just using   cp /dev/null new.file   but of course
this only works for one file at a time.  I've had a script around for a while 
called "wipe" that will create an arbitrary number of zero-length files:

			#! /bin/sh
			exec /bin/tee $* < /dev/null

[BTW, I hadn't looked at the date of the original posting, either.  I must
have been reading it before my morning's coffee because I can remember
puzzling for a good 30 seconds over why you'd want an echo that didn't print
its arguments. :-)]
-- 
------------------------------------------------------------------------------

Ray Lubinsky		     University of Virginia, Dept. of Computer Science
			     uucp: decvax!mcnc!ncsu!uvacs!rwl

mjb@iris.UUCP (Mike Braca) (04/13/85)

In csh the command:
	alias \> cp /dev/null
allows you to type
	>xxx
to create an empty file, just like in sh.
................................................................
Mike Braca, Brown Univ/IRIS, "Home of the Scholar's Workstation"
 brunix!iris!mjb  ||  mjb%iris@Brown.CSNet  ||  MJB@IRIS.BITNET

jsdy@hadron.UUCP (Joseph S. D. Yao) (04/16/85)

> On every UNIX system I have ever used, there is no way to prevent
> the echo command from printing its arguments.  I would like to
> propose a "-q" option to echo which tells it to be quiet and go about
> its work without printing its arguments.

I don't understand this posting at all.  I always thought that
"the work" of echo  w a s  to print its arguments.	;-S

	Joe Yao		hadron!jsdy@seismo.{ARPA,UUCP}

honey@down.FUN (code 101) (04/16/85)

alias '>' 'tee \!* < /dev/null'

this has the advantage of allowing
	> f1 f2 ...

	peter

jbdp%cl.cam@ucl-cs.arpa (Julian Pardoe) (04/19/85)

I  assumed `echo -q' was a joke;  if people want echo not to
echo any arguments, say to create a file,  why not just give
it no arguments?

Julian Pardoe

peter@rlgvax.UUCP (Peter Klosky) (04/22/85)

trmsg(na)
+++ Using echo to put data on the file system can be tricky.
+++ The following script would truncate it's file regularly due to
+++ the window between the shell performing
+++ the i/o redirection and the echo program being invoked, given 
+++ a signal in the window.

if test -f .jobname
 then
     lastjob=`cat .jobname`
else
     lastjob=0
fi
thisjob=`expr $lastjob + 1`
echo $thisjob >.jobname