File: Current-Working-Directory.html

package info (click to toggle)
octave 10.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 145,388 kB
  • sloc: cpp: 335,976; ansic: 82,241; fortran: 20,963; objc: 9,402; sh: 8,756; yacc: 4,392; lex: 4,333; perl: 1,544; java: 1,366; awk: 1,259; makefile: 659; xml: 192
file content (213 lines) | stat: -rw-r--r-- 13,218 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Current Working Directory (GNU Octave (version 10.3.0))</title>

<meta name="description" content="Current Working Directory (GNU Octave (version 10.3.0))">
<meta name="keywords" content="Current Working Directory (GNU Octave (version 10.3.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="System-Utilities.html" rel="up" title="System Utilities">
<link href="Password-Database-Functions.html" rel="next" title="Password Database Functions">
<link href="Environment-Variables.html" rel="prev" title="Environment Variables">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">


</head>

<body lang="en">
<div class="section-level-extent" id="Current-Working-Directory">
<div class="nav-panel">
<p>
Next: <a href="Password-Database-Functions.html" accesskey="n" rel="next">Password Database Functions</a>, Previous: <a href="Environment-Variables.html" accesskey="p" rel="prev">Environment Variables</a>, Up: <a href="System-Utilities.html" accesskey="u" rel="up">System Utilities</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Current-Working-Directory-1"><span>36.8 Current Working Directory<a class="copiable-link" href="#Current-Working-Directory-1"> &para;</a></span></h3>

<a class="anchor" id="XREFcd"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-cd-3"><span><strong class="def-name">cd</strong> <code class="def-code-arguments"><var class="var">dir</var></code><a class="copiable-link" href="#index-cd-3"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-cd-4"><span><strong class="def-name">cd</strong><a class="copiable-link" href="#index-cd-4"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-cd-5"><span><code class="def-type"><var class="var">old_dir</var> =</code> <strong class="def-name">cd</strong><a class="copiable-link" href="#index-cd-5"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-cd-6"><span><code class="def-type"><var class="var">old_dir</var> =</code> <strong class="def-name">cd</strong> <code class="def-code-arguments">(<var class="var">dir</var>)</code><a class="copiable-link" href="#index-cd-6"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-chdir"><span><strong class="def-name">chdir</strong> <code class="def-code-arguments">&hellip;</code><a class="copiable-link" href="#index-chdir"> &para;</a></span></dt>
<dd><p>Change the current working directory to <var class="var">dir</var>.
</p>
<p>If called with no input or output arguments, the current directory is
changed to the user&rsquo;s home directory (<code class="code">&quot;~&quot;</code>).
</p>
<p>For example,
</p>
<div class="example">
<pre class="example-preformatted">cd ~/octave
</pre></div>

<p>changes the current working directory to <samp class="file">~/octave</samp>.  If the
directory does not exist, an error message is printed and the working
directory is not changed.
</p>
<p>Programming Note: <code class="code">chdir</code> is an alias for <code class="code">cd</code> and can be used with
all of the same calling formats.
</p>
<p>Compatibility Note: When called with no arguments, <small class="sc">MATLAB</small> prints the
present working directory rather than changing to the user&rsquo;s home directory.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFpwd">pwd</a>, <a class="ref" href="Filesystem-Utilities.html#XREFmkdir">mkdir</a>, <a class="ref" href="Filesystem-Utilities.html#XREFrmdir">rmdir</a>, <a class="ref" href="#XREFdir">dir</a>, <a class="ref" href="#XREFls">ls</a>.
</p></dd></dl>


<a class="anchor" id="XREFls"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-ls"><span><strong class="def-name">ls</strong><a class="copiable-link" href="#index-ls"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-ls-1"><span><strong class="def-name">ls</strong> <code class="def-code-arguments"><var class="var">filenames</var></code><a class="copiable-link" href="#index-ls-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-ls-2"><span><strong class="def-name">ls</strong> <code class="def-code-arguments"><var class="var">options</var></code><a class="copiable-link" href="#index-ls-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-ls-3"><span><strong class="def-name">ls</strong> <code class="def-code-arguments"><var class="var">options</var> <var class="var">filenames</var></code><a class="copiable-link" href="#index-ls-3"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-ls-4"><span><code class="def-type"><var class="var">list</var> =</code> <strong class="def-name">ls</strong> <code class="def-code-arguments">(&hellip;)</code><a class="copiable-link" href="#index-ls-4"> &para;</a></span></dt>
<dd>
<p>List directory contents.
</p>
<p>The <code class="code">ls</code> function forwards to the <code class="code">ls</code> command if it is available.
It falls back to calling the native operating system&rsquo;s directory listing
command.  Available <var class="var">options</var> may vary from system to system.
</p>
<p>Filenames are subject to shell expansion if they contain any wildcard
characters &lsquo;<samp class="samp">*</samp>&rsquo;, &lsquo;<samp class="samp">?</samp>&rsquo;, &lsquo;<samp class="samp">[]</samp>&rsquo;.  If these wildcard characters are
escaped with a backslash &lsquo;<samp class="samp">\</samp>&rsquo; (e.g., &lsquo;<samp class="samp">\*</samp>&rsquo;) then they are not
treated as wildcards, but instead as the corresponding literal character.
</p>
<p>If the optional output <var class="var">list</var> is requested then <code class="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">
<div class="group"><pre class="example-preformatted">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></div>


<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFdir">dir</a>, <a class="ref" href="Filesystem-Utilities.html#XREFreaddir">readdir</a>, <a class="ref" href="Filesystem-Utilities.html#XREFglob">glob</a>, <a class="ref" href="Status-of-Variables.html#XREFwhat">what</a>, <a class="ref" href="Filesystem-Utilities.html#XREFstat">stat</a>, <a class="ref" href="Filesystem-Utilities.html#XREFfilesep">filesep</a>, <a class="ref" href="#XREFls_005fcommand">ls_command</a>.
</p></dd></dl>


<a class="anchor" id="XREFls_005fcommand"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-ls_005fcommand"><span><code class="def-type"><var class="var">val</var> =</code> <strong class="def-name">ls_command</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-ls_005fcommand"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-ls_005fcommand-1"><span><code class="def-type"><var class="var">old_val</var> =</code> <strong class="def-name">ls_command</strong> <code class="def-code-arguments">(<var class="var">new_val</var>)</code><a class="copiable-link" href="#index-ls_005fcommand-1"> &para;</a></span></dt>
<dd><p>Query or set the shell command used by Octave&rsquo;s <code class="code">ls</code> command.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFls">ls</a>.
</p></dd></dl>


<a class="anchor" id="XREFdir"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-dir-2"><span><strong class="def-name">dir</strong><a class="copiable-link" href="#index-dir-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-dir-3"><span><strong class="def-name">dir</strong> <code class="def-code-arguments"><var class="var">directory</var></code><a class="copiable-link" href="#index-dir-3"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-dir-4"><span><code class="def-type">[<var class="var">list</var>] =</code> <strong class="def-name">dir</strong> <code class="def-code-arguments">(<var class="var">directory</var>)</code><a class="copiable-link" href="#index-dir-4"> &para;</a></span></dt>
<dd><p>Display file listing for directory <var class="var">directory</var>.
</p>
<p>If <var class="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 class="table">
<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 class="code">stat</code>.
</p></dd>
</dl>

<p>If <var class="var">directory</var> is a filename, rather than a directory, then return
information about the named file.  <var class="var">directory</var> may also be a list rather
than a single directory or file.
</p>
<p><var class="var">directory</var> is subject to shell expansion if it contains any wildcard
characters &lsquo;<samp class="samp">*</samp>&rsquo;, &lsquo;<samp class="samp">?</samp>&rsquo;, &lsquo;<samp class="samp">[]</samp>&rsquo;.  If these wildcard characters are
escaped with a backslash &lsquo;<samp class="samp">\</samp>&rsquo; (e.g., &lsquo;<samp class="samp">\*</samp>&rsquo;) on a POSIX platform,
then they are not treated as wildcards, but as the corresponding literal
character.  On Windows, it is not possible to escape wildcard characters
because backslash &lsquo;<samp class="samp">\</samp>&rsquo; is treated as a file separator.  On Windows, use
<code class="code">ls</code> for file or folder names that contain characters that would be
treated as wildcards by <code class="code">dir</code>.
</p>
<p>Note that for symbolic links, <code class="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 class="code">dir</code> returns information
about the link.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFls">ls</a>, <a class="ref" href="Filesystem-Utilities.html#XREFreaddir">readdir</a>, <a class="ref" href="Filesystem-Utilities.html#XREFglob">glob</a>, <a class="ref" href="Status-of-Variables.html#XREFwhat">what</a>, <a class="ref" href="Filesystem-Utilities.html#XREFstat">stat</a>, <a class="ref" href="Filesystem-Utilities.html#XREFlstat">lstat</a>.
</p></dd></dl>


<a class="anchor" id="XREFpwd"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-pwd"><span><code class="def-type"><var class="var">dir</var> =</code> <strong class="def-name">pwd</strong> <code class="def-code-arguments">()</code><a class="copiable-link" href="#index-pwd"> &para;</a></span></dt>
<dd><p>Return the current working directory.
</p>
<p><strong class="strong">See also:</strong> <a class="ref" href="#XREFcd">cd</a>, <a class="ref" href="#XREFdir">dir</a>, <a class="ref" href="#XREFls">ls</a>, <a class="ref" href="Filesystem-Utilities.html#XREFmkdir">mkdir</a>, <a class="ref" href="Filesystem-Utilities.html#XREFrmdir">rmdir</a>.
</p></dd></dl>


</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Password-Database-Functions.html">Password Database Functions</a>, Previous: <a href="Environment-Variables.html">Environment Variables</a>, Up: <a href="System-Utilities.html">System Utilities</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>