Chdir
Encyclopedia : C : CH : CHD : Chdir
- The correct title of this } is }}}. The initial letter is capitalized due to [Naming conventions #Lower case first lettertechnical restrictions].
chdir() POSIX C function) and in DOS's COMMAND.COM.A directory is a logical section of a filesystem used to hold files. Directories may also contain other directories. The cd command can be used to change into a subdirectory, move back into the parent directory, move all the way back to the root (/ in UNIX, \ in DOS) or move to any given directory.
Consider the following subsection of a Unix filesystem, which shows a user's home directory (represented as "~") with a file ("text.txt") and three subdirectories.

If the user's current working directory is the home directory ("~"), then entering the command "ls" followed by "cd games" might produce the following transcript:
me@host:~$ ls workreports games encyclopedia text.txt me@host:~$ cd games me@host:games$The user is now in the "games" directory.
A similar session in DOS (though the concept of a "home directory" may not apply, depending on the specific version) would look like this:
C:\> dir workreportsNote that cd has different effects on different operating systems if given with no arguments. For example, if executed without arguments in DOS, the current working directory is printed. If executed without arguments in Unix, then the user is returned to the home directory. The effect of executing the cd command within a script or batch file also varies. In DOS, the caller's current directory can be directly altered by the batch file's use of this command. In Unix the caller's current directory is not altered by the script's invocation of the cd command. This is because in Unix, the script is usually executed within a subshell.Wed Oct 9th 9:01 games Tue Oct 8th 14:32 encyclopedia Mon Oct 1st 10:05 text txt 1903 Thu Oct10th 12:43 C:\> cd games C:\games>
CHDIR() is also a Visual Basic function which changes the working directory.See also
| Unix command line programs ( ) | |||
| File and file system management: | cat | chdir/cd | chmod | chown | chgrp | cp | du | df | fdupes | file | fsck | ln | ls | lsof | mkdir | more | mount | mv | pwd | rcp | rm | rmdir | split | touch | tree | ||
| Process management: | anacron | at | chroot | cron/crontab | kill | nice | ps | sleep | time | timex | top | renice | wait | ||
| User Management/Environment: | env | finger | id | locale | mesg | passwd | su | sudo | uname | uptime | w | who | write | ||
| Text processing: | awk | cut | diff | ex | head | iconv | join | less | more | nkf | paste | sed | sort | tail | tr | uniq | wc | xargs | ||
| Shell programming: | echo | expr | unset | Printing: | lp |
| Communications: inetd | netstat | ping | rlogin | traceroute | Searching: egrep | fgrep | find | grep | strings | Miscellaneous: banner | bc | cal | man | uname | wall | yes | |
From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.
