Next: Password Database Functions, Previous: Environment Variables, Up: System Utilities [Contents][Index]

### 36.8 Current Working Directory

Command: cd dir
Command: cd
Built-in Function: old_dir = cd dir
Command: chdir …

  Change the current working directory to dir.

  If dir is omitted, the current directory is changed to the user’s home directory (`"~"`).

  For example,

      cd ~/octave

  changes the current working directory to `~/octave`. If the directory does not exist, an error message is printed and the working directory is not changed.

  `chdir` is an alias for `cd` and can be used in all of the same calling formats.

  Compatibility Note: When called with no arguments, MATLAB prints the present working directory rather than changing to the user’s home directory.

  See also: pwd, mkdir, rmdir, dir, ls.

Command: ls
Command: ls filenames
Command: ls options
Command: ls options filenames

  List directory contents. For example:

      ls -l
           -| total 12
           -| -rw-r--r--   1 jwe  users  4488 Aug 19 04:02 foo.m
           -| -rw-r--r--   1 jwe  users  1315 Aug 17 23:14 bar.m

  The `dir` and `ls` commands are implemented by calling your system’s directory listing command, so the available options will vary from system to system.

  Filenames are subject to shell expansion if they contain any wildcard characters ‘`*`’, ‘`?`’, ‘`[]`’. If you want to find a literal example of a wildcard character you must escape it using the backslash operator ‘`\`’.

  See also: dir, readdir, glob, what, stat, filesep, ls_command.

Function File: val = ls_command ()
Function File: old_val = ls_command (new_val)

  Query or set the shell command used by Octave’s `ls` command.

  See also: ls.

Function File: dir
Function File: dir (directory)
Function File: [list] = dir (directory)

  Display file listing for directory directory.

  If directory is not specified then list the present working directory.

  If a return value is requested, return a structure array with the fields

  name

    File or directory name.

  date

    Timestamp of file modification (string value).

  bytes

    File size in bytes.

  isdir

    True if name is a directory.

  datenum

    Timestamp of file modification as serial date number (double).

  statinfo

    Information structure returned from `stat`.

  If directory is a filename, rather than a directory, then return information about the named file. directory may also be a list rather than a single directory or file.

  directory is subject to shell expansion if it contains any wildcard characters ‘`*`’, ‘`?`’, ‘`[]`’. If you want to find a literal example of a wildcard character you must escape it using the backslash operator ‘`\`’.

  Note that for symbolic links, `dir` returns information about the file that the symbolic link points to rather than the link itself. However, if the link points to a nonexistent file, `dir` returns information about the link.

  See also: ls, readdir, glob, what, stat.

Built-in Function: pwd ()
Built-in Function: dir = pwd ()

  Return the current working directory.

  See also: cd, dir, ls, mkdir, rmdir.

Next: Password Database Functions, Previous: Environment Variables, Up: System Utilities [Contents][Index]