dapper sudo

Erik Christiansen erik at dd.nec.com.au
Wed Jul 5 08:55:11 UTC 2006


On Tue, Jul 04, 2006 at 11:41:31PM -0700, Jack Bowling wrote:
> > > sudo cat /dev/null >  /var/log/apache2/error.log

...

> 
> Could somebody tell me if there is any difference between the above cat
> command and 
> 
> [sudo] echo "" > /var/log/apache2/error.log
> 
> assuming one has sudo'ed to a root shell?

Jack,

The most obvious difference lies not in privilege, but in the implicit
newline generated by the bash builtin echo:

erik at dvalin:~$ cat /dev/null > /tmp/fred ; echo "" > /tmp/jim ; ll /tmp/fred /tmp/jim
-rw-r--r--  1 erik staff 0 2006-07-05 18:45 /tmp/fred
-rw-r--r--  1 erik staff 1 2006-07-05 18:45 /tmp/jim

erik at dvalin:~$ which echo
echo is a shell builtin

erik at dvalin:~$ echo -n "" > /tmp/jim ; ll /tmp/jim
-rw-r--r--  1 erik staff 0 2006-07-05 18:47 /tmp/jim

Now the echo is also generating an empty file.

Erik




More information about the ubuntu-users mailing list