<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Current Working Directory (GNU Octave (version 5.1.0))</title> <meta name="description" content="Current Working Directory (GNU Octave (version 5.1.0))"> <meta name="keywords" content="Current Working Directory (GNU Octave (version 5.1.0))"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> <link href="index.html#Top" rel="start" title="Top"> <link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="System-Utilities.html#System-Utilities" rel="up" title="System Utilities"> <link href="Password-Database-Functions.html#Password-Database-Functions" rel="next" title="Password Database Functions"> <link href="Environment-Variables.html#Environment-Variables" rel="prev" title="Environment Variables"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} blockquote.smallindentedblock {margin-right: 0em; font-size: smaller} blockquote.smallquotation {font-size: smaller} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} div.lisp {margin-left: 3.2em} div.smalldisplay {margin-left: 3.2em} div.smallexample {margin-left: 3.2em} div.smalllisp {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: inherit; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: inherit; font-size: smaller} pre.smalllisp {font-size: smaller} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} ul.no-bullet {list-style: none} --> </style> <link rel="stylesheet" type="text/css" href="octave.css"> </head> <body lang="en"> <a name="Current-Working-Directory"></a> <div class="header"> <p> Next: <a href="Password-Database-Functions.html#Password-Database-Functions" accesskey="n" rel="next">Password Database Functions</a>, Previous: <a href="Environment-Variables.html#Environment-Variables" accesskey="p" rel="prev">Environment Variables</a>, Up: <a href="System-Utilities.html#System-Utilities" accesskey="u" rel="up">System Utilities</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> <hr> <a name="Current-Working-Directory-1"></a> <h3 class="section">36.8 Current Working Directory</h3> <a name="XREFcd"></a><dl> <dt><a name="index-cd-2"></a><em></em> <strong>cd</strong> <em><var>dir</var></em></dt> <dt><a name="index-cd-3"></a><em></em> <strong>cd</strong></dt> <dt><a name="index-cd-4"></a><em><var>old_dir</var> =</em> <strong>cd</strong> <em>(<var>dir</var>)</em></dt> <dt><a name="index-chdir"></a><em></em> <strong>chdir</strong> <em>…</em></dt> <dd><p>Change the current working directory to <var>dir</var>. </p> <p>If <var>dir</var> is omitted, the current directory is changed to the user’s home directory (<code>"~"</code>). </p> <p>For example, </p> <div class="example"> <pre class="example">cd ~/octave </pre></div> <p>changes the current working directory to <samp>~/octave</samp>. If the directory does not exist, an error message is printed and the working directory is not changed. </p> <p><code>chdir</code> is an alias for <code>cd</code> and can be used in all of the same calling formats. </p> <p>Compatibility Note: When called with no arguments, <small>MATLAB</small> prints the present working directory rather than changing to the user’s home directory. </p> <p><strong>See also:</strong> <a href="#XREFpwd">pwd</a>, <a href="Filesystem-Utilities.html#XREFmkdir">mkdir</a>, <a href="Filesystem-Utilities.html#XREFrmdir">rmdir</a>, <a href="#XREFdir">dir</a>, <a href="#XREFls">ls</a>. </p></dd></dl> <a name="XREFls"></a><dl> <dt><a name="index-ls"></a><em></em> <strong>ls</strong></dt> <dt><a name="index-ls-1"></a><em></em> <strong>ls</strong> <em><var>filenames</var></em></dt> <dt><a name="index-ls-2"></a><em></em> <strong>ls</strong> <em><var>options</var></em></dt> <dt><a name="index-ls-3"></a><em></em> <strong>ls</strong> <em><var>options</var> <var>filenames</var></em></dt> <dt><a name="index-ls-4"></a><em><var>list</var> =</em> <strong>ls</strong> <em>(…)</em></dt> <dd> <p>List directory contents. </p> <p>The <code>ls</code> command is implemented by calling the native operating system’s directory listing command—available <var>options</var> will vary from system to system. </p> <p>Filenames are subject to shell expansion if they contain any wildcard characters ‘<samp>*</samp>’, ‘<samp>?</samp>’, ‘<samp>[]</samp>’. To find a literal example of a wildcard character the wildcard must be escaped using the backslash operator ‘<samp>\</samp>’. </p> <p>If the optional output <var>list</var> is requested then <code>ls</code> returns a character array with one row for each file/directory name. </p> <p>Example usage on a UNIX-like system: </p> <div class="example"> <pre class="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 </pre></div> <p><strong>See also:</strong> <a href="#XREFdir">dir</a>, <a href="Filesystem-Utilities.html#XREFreaddir">readdir</a>, <a href="Filesystem-Utilities.html#XREFglob">glob</a>, <a href="Status-of-Variables.html#XREFwhat">what</a>, <a href="Filesystem-Utilities.html#XREFstat">stat</a>, <a href="Filesystem-Utilities.html#XREFfilesep">filesep</a>, <a href="#XREFls_005fcommand">ls_command</a>. </p></dd></dl> <a name="XREFls_005fcommand"></a><dl> <dt><a name="index-ls_005fcommand"></a><em><var>val</var> =</em> <strong>ls_command</strong> <em>()</em></dt> <dt><a name="index-ls_005fcommand-1"></a><em><var>old_val</var> =</em> <strong>ls_command</strong> <em>(<var>new_val</var>)</em></dt> <dd><p>Query or set the shell command used by Octave’s <code>ls</code> command. </p> <p><strong>See also:</strong> <a href="#XREFls">ls</a>. </p></dd></dl> <a name="XREFdir"></a><dl> <dt><a name="index-dir-1"></a><em></em> <strong>dir</strong></dt> <dt><a name="index-dir-2"></a><em></em> <strong>dir</strong> <em>(<var>directory</var>)</em></dt> <dt><a name="index-dir-3"></a><em>[<var>list</var>] =</em> <strong>dir</strong> <em>(<var>directory</var>)</em></dt> <dd><p>Display file listing for directory <var>directory</var>. </p> <p>If <var>directory</var> is not specified then list the present working directory. </p> <p>If a return value is requested, return a structure array with the fields </p> <dl compact="compact"> <dt>name</dt> <dd><p>File or directory name. </p> </dd> <dt>folder</dt> <dd><p>Location of file or directory </p> </dd> <dt>date</dt> <dd><p>Timestamp of file modification (string value). </p> </dd> <dt>bytes</dt> <dd><p>File size in bytes. </p> </dd> <dt>isdir</dt> <dd><p>True if name is a directory. </p> </dd> <dt>datenum</dt> <dd><p>Timestamp of file modification as serial date number (double). </p> </dd> <dt>statinfo</dt> <dd><p>Information structure returned from <code>stat</code>. </p></dd> </dl> <p>If <var>directory</var> is a filename, rather than a directory, then return information about the named file. <var>directory</var> may also be a list rather than a single directory or file. </p> <p><var>directory</var> is subject to shell expansion if it contains any wildcard characters ‘<samp>*</samp>’, ‘<samp>?</samp>’, ‘<samp>[]</samp>’. To find a literal example of a wildcard character the wildcard must be escaped using the backslash operator ‘<samp>\</samp>’. </p> <p>Note that for symbolic links, <code>dir</code> 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, <code>dir</code> returns information about the link. </p> <p><strong>See also:</strong> <a href="#XREFls">ls</a>, <a href="Filesystem-Utilities.html#XREFreaddir">readdir</a>, <a href="Filesystem-Utilities.html#XREFglob">glob</a>, <a href="Status-of-Variables.html#XREFwhat">what</a>, <a href="Filesystem-Utilities.html#XREFstat">stat</a>, <a href="Filesystem-Utilities.html#XREFlstat">lstat</a>. </p></dd></dl> <a name="XREFpwd"></a><dl> <dt><a name="index-pwd"></a><em></em> <strong>pwd</strong> <em>()</em></dt> <dt><a name="index-pwd-1"></a><em><var>dir</var> =</em> <strong>pwd</strong> <em>()</em></dt> <dd><p>Return the current working directory. </p> <p><strong>See also:</strong> <a href="#XREFcd">cd</a>, <a href="#XREFdir">dir</a>, <a href="#XREFls">ls</a>, <a href="Filesystem-Utilities.html#XREFmkdir">mkdir</a>, <a href="Filesystem-Utilities.html#XREFrmdir">rmdir</a>. </p></dd></dl> <hr> <div class="header"> <p> Next: <a href="Password-Database-Functions.html#Password-Database-Functions" accesskey="n" rel="next">Password Database Functions</a>, Previous: <a href="Environment-Variables.html#Environment-Variables" accesskey="p" rel="prev">Environment Variables</a>, Up: <a href="System-Utilities.html#System-Utilities" accesskey="u" rel="up">System Utilities</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p> </div> </body> </html>