|
Article on other languages:
|
cd, sometimes also available as chdir (change directory), is a command line command to change the current working directory in operating systems such as Unix, DOS, OS/2 and Windows. It is also available for use in shell scripts and batch files. chdir(2) is the system call which changes the working directory, as defined by POSIX.
UsageA directory is a logical section of a file system 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 directory 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 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 workreports <DIR> Wed Oct 9th 9:01 games <DIR> Tue Oct 8th 14:32 encyclopedia <DIR> Mon Oct 1st 10:05 text txt 1903 Thu Oct10th 12:43 C:\> cd games C:\games> Note that cd has different effects on different operating systems if given with no arguments. For example, if executed without arguments in DOS, OS/2, or Windows, 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. Options (version specific)
How it workscd is frequently included built directly into the command line interpreter. This is the case in most of the Unix shells (Bourne shell, tcsh, bash, etc.), cmd.exe and Windows PowerShell on Windows and COMMAND.COM on DOS. Command line shells on Windows usually use the Windows API to change the current working directory, whereas on Unix systems cd calls the Windows PowerShell, Microsoft's new object-oriented command line shell and scripting language executes the cd command (cmdlet) within the shell's process. However, since PowerShell is based on the .NET Framework and has a different architecture than previous shells, all of PowerShell's cmdlets like ls, rm etc. run in the shell's process. Of course, this is not true for legacy commands which still run in a separate process. References
See also
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net