Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'bad find results?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
bad find results?
Authored by: gabester on Apr 30, '01 11:12:24AM

When I ran the first part of this command, the output was similar to as follows (usernames have been changed to protect my innocence):

/dev/fd/3/.Trash
find: /dev/fd/4: No such file or directory
/Users/root/.Trash
/Users/mainuser/.Trash
/Users/guest/.Trash
/Volumes/Users/mainuserbackup/.Trash

I'm thinking if the second line of this result gets piped to the rm command, something chokes?
I'm no UNIX expert, just a casual user. What does the "find: /dev/fd/4: No such..." message mean?
Also, trying to look at /dev/fd/3 and 4 gives me "bad file descriptor" errors.

I also note that on my numerous drive volumes (I have several partitions) there are other trashes that didn't get listed by this command...

So my hunch is if you can run the find without funny stuff, piping it to rm will work fine, but if you get errors from the find then piping to rm will choke your unix subsystem up a bit. Experts, what does the survey say?

g=



[ Reply to This | # ]
bad find results?
Authored by: robh on Apr 30, '01 06:23:36PM

The line of output
find: /dev/fd/4: No such file or directory
is almost certainly sent to STDERR rather than STDOUT, so it won't get passed on to the 'rm' command.

By default, when a unix command line program outputs text, it is printed to STDOUT (standard output). If the app wants to report an error then it prints to STDERR (standard error) instead.

Try these commands
ls /Applications /foobar | wc -l
ls /Applications /foobar |& wc -l

I'm assuming /foobar doesn't exist. In the first command you should see the error message 'ls: /foobar: No such file or directory' and only the filenames in /Applications are passed to the 'wc -l' command (which counts lines) and tells you how many there were. In the second line, I've added a '&' after '|' pipe. In the tcsh (and csh) shell, '|&' means combine STDOUT and STDERR, so the error message doesn't appear in the terminal, it gets piped into the 'wc -l' command instead and the number of lines counted should now be 1 more than for the first command.

To answer the question 'What does the "find: /dev/fd/4: No such..." message mean?'...
/dev is a directory full of unix devices. Unix gives access to all (I think) devices as if you were accessing a file. /dev contains a bunch of devices that the system has access to or is able to support even if you don't have the device (yet).

Try this...
In the terminal preferences, check the "device name" checkbox under "Title Bar".
Now open a new terminal window (command-N)
You should see something like (ttyp2) in the title of the new terminal. Go back to the first terminal and type 'echo hello >/dev/ttyp2' (change the '2' to match the new terminal's title)
You should then see the 'hello' appear in the 2nd terminal.
/dev/ttyp2 is the filename that interfaces to the terminal device.

If you do 'ls -l /dev' you see things like this...
crw-rw-rw- 1 root wheel 1, 0 Apr 14 15:28 cu.modem
brw-r----- 1 root operator 14, 0 Apr 14 15:27 disk0
crw-rw-rw- 1 root wheel 5, 2 Apr 30 23:06 ptyp2

Unlike other files, you'll see the letters 'c' and 'b' at the beginning of the line. These refer to 'character' and 'block' devices. Character devices work with streams of characters, 1 at a time. Block devices manipulate blocks of data. If you attempt to write directly to a block device, you probably won't get far...
echo 'hello' > /dev/disk0
/dev/disk0: Permission denied.
Unix doesn't want you writing character garbage onto its block devices.



[ Reply to This | # ]