Sponsored Content
Full Discussion: Cd
Top Forums UNIX for Dummies Questions & Answers Cd Post 7944 by Neo on Wednesday 3rd of October 2001 09:00:54 PM
Old 10-03-2001
Perhaps it would help if we looked at /usr/bin/cd, not from the context of listing files in a directory in an interactive shell, but for a command sequence:

NOTE: MAY NOT WORK.... TRY WITH EXTREME CAUTION !!!

/usr/bin/cd /tmp; rm -rf *

NOTE: MAY NOT WORK.... TRY WITH EXTREME CAUTION !!!

This would appear, if I'm not mistaken, to spawn a child process that would remove all the files in the /tmp directory. After that task completes and the child process exists; the original shell process and current directory would be the same as before the command sequence was executed.

Another example might be as simple as:

/usr/bin/cd /usr/spool/mail; ls -la > /tmp/mail_stuff

One could argue that the sequence:

ls -la /usr/spool/mail > /tmp/mail_stuff

would accomplish the same thing.... agreed.

However, it seems that there are numerous possible scenarios where /usr/bin/cd could be useful when used in a command line sequence and subshell
 
BINMAIL(1)						      General Commands Manual							BINMAIL(1)

NAME
binmail - send or receive mail among users SYNOPSIS
/bin/mail [ + ] [ -i ] [ person ] ... /bin/mail [ + ] [ -i ] -f file DESCRIPTION
Note: This is the old version 7 UNIX system mail program. The default mail command is described in Mail(1), and its binary is in the directory /usr/ucb. mail with no argument prints a user's mail, message-by-message, in last-in, first-out order; the optional argument + displays the mail mes- sages in first-in, first-out order. For each message, it reads a line from the standard input to direct disposition of the message. newline Go on to next message. d Delete message and go on to the next. p Print message again. - Go back to previous message. s [ file ] ... Save the message in the named files (`mbox' default). w [ file ] ... Save the message, without a header, in the named files (`mbox' default). m [ person ] ... Mail the message to the named persons (yourself is default). EOT (control-D) Put unexamined mail back in the mailbox and stop. q Same as EOT. !command Escape to the Shell to do command. * Print a command summary. An interrupt normally terminates the mail command; the mail file is unchanged. The optional argument -i tells mail to continue after interrupts. When persons are named, mail takes the standard input up to an end-of-file (or a line with just `.') and adds it to each person's `mail' file. The message is preceded by the sender's name and a postmark. Lines that look like postmarks are prepended with `>'. A person is usually a user name recognized by login(1). To denote a recipient on a remote system, prefix person by the system name and exclamation mark (see uucp(1C)). The -f option causes the named file, for example, `mbox', to be printed as if it were the mail file. When a user logs in he is informed of the presence of mail. FILES
/etc/passwd to identify sender and locate persons /usr/spool/mail/* incoming mail for user * mbox saved mail /tmp/ma* temp file /usr/spool/mail/*.lock lock for mail directory dead.letter unmailable text SEE ALSO
Mail(1), write(1), uucp(1C), uux(1C), xsend(1), sendmail(8) BUGS
Race conditions sometimes result in a failure to remove a lock file. Normally anybody can read your mail, unless it is sent by xsend(1). An installation can overcome this by making mail a set-user-id command that owns the mail directory. 7th Edition April 29, 1985 BINMAIL(1)
All times are GMT -4. The time now is 09:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy