slackware-current/slackbook/html/file-commands-creation.html
Patrick J Volkerding 75a4a592e5 Slackware 13.37
Mon Apr 25 13:37:00 UTC 2011
Slackware 13.37 x86_64 stable is released!

Thanks to everyone who pitched in on this release: the Slackware team,
the folks producing upstream code, and linuxquestions.org for providing
a great forum for collaboration and testing.

The ISOs are off to be replicated, a 6 CD-ROM 32-bit set and a
dual-sided
32-bit/64-bit x86/x86_64 DVD.  Please consider supporting the Slackware
project by picking up a copy from store.slackware.com.  We're taking
pre-orders now, and offer a discount if you sign up for a subscription.

As always, thanks to the Slackware community for testing, suggestions,
and feedback.  :-)

Have fun!
2018-05-31 22:45:18 +02:00

143 lines
4.8 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org" />
<title>Creation: touch and mkdir</title>
<meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" />
<link rel="HOME" title="Slackware Linux Essentials" href="index.html" />
<link rel="UP" title="Handling Files and Directories" href="file-commands.html" />
<link rel="PREVIOUS" title="Simple Output: cat and echo"
href="file-commands-output.html" />
<link rel="NEXT" title="Copy and Move" href="file-commands-copymove.html" />
<link rel="STYLESHEET" type="text/css" href="docbook.css" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"
alink="#0000FF">
<div class="NAVHEADER">
<table summary="Header navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<th colspan="3" align="center">Slackware Linux Essentials</th>
</tr>
<tr>
<td width="10%" align="left" valign="bottom"><a href="file-commands-output.html"
accesskey="P">Prev</a></td>
<td width="80%" align="center" valign="bottom">Chapter 10 Handling Files and
Directories</td>
<td width="10%" align="right" valign="bottom"><a href="file-commands-copymove.html"
accesskey="N">Next</a></td>
</tr>
</table>
<hr align="LEFT" width="100%" />
</div>
<div class="SECT1">
<h1 class="SECT1"><a id="FILE-COMMANDS-CREATION" name="FILE-COMMANDS-CREATION">10.4
Creation: <tt class="COMMAND">touch</tt> and <tt class="COMMAND">mkdir</tt></a></h1>
<div class="SECT2">
<h2 class="SECT2"><a id="AEN3619" name="AEN3619">10.4.1 <tt
class="COMMAND">touch</tt></a></h2>
<p><tt class="COMMAND">touch</tt>(1) is used to change the timestamp on a file. You can
change access timestamps and modification timestamps with this command. If the file
specified does not exist, <tt class="COMMAND">touch</tt> will create a zero length file
with the name specified. To mark a file with the current system time, you would issue
this command:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">ls -al file1</kbd>
-rw-r--r-- 1 root root 9779 Feb 7 21:41 file1
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">touch file1</kbd>
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">ls -al file1</kbd>
-rw-r--r-- 1 root root 9779 Feb 8 09:17 file1
</pre>
</td>
</tr>
</table>
<p>There are several options for <tt class="COMMAND">touch</tt>, including options to
specify which timestamp to modify, the time to use, and many more. The online manual page
discusses these in detail.</p>
</div>
<div class="SECT2">
<h2 class="SECT2"><a id="AEN3639" name="AEN3639">10.4.2 <tt
class="COMMAND">mkdir</tt></a></h2>
<p><tt class="COMMAND">mkdir</tt>(1) will create a new directory. You simply specify the
directory to create when you run mkdir. This example creates the <tt
class="FILENAME">hejaz</tt> directory in the current directory:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">mkdir hejaz</kbd>
</pre>
</td>
</tr>
</table>
<p>You can also specify a path, like this:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">mkdir /usr/local/hejaz</kbd>
</pre>
</td>
</tr>
</table>
<p>The <var class="OPTION">-p</var> option will tell <tt class="COMMAND">mkdir</tt> to
make any parent directories. The above example will fail if <tt
class="COMMAND">/usr/local</tt> does not exist. The <var class="OPTION">-p</var> option
will create <tt class="FILENAME">/usr/local</tt> and <tt
class="FILENAME">/usr/local/hejaz</tt>:</p>
<table border="0" bgcolor="#E0E0E0" width="100%">
<tr>
<td>
<pre class="SCREEN">
<samp class="PROMPT">%</samp> <kbd class="USERINPUT">mkdir -p /usr/local/hejaz</kbd>
</pre>
</td>
</tr>
</table>
</div>
</div>
<div class="NAVFOOTER">
<hr align="LEFT" width="100%" />
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0"
cellspacing="0">
<tr>
<td width="33%" align="left" valign="top"><a href="file-commands-output.html"
accesskey="P">Prev</a></td>
<td width="34%" align="center" valign="top"><a href="index.html"
accesskey="H">Home</a></td>
<td width="33%" align="right" valign="top"><a href="file-commands-copymove.html"
accesskey="N">Next</a></td>
</tr>
<tr>
<td width="33%" align="left" valign="top">Simple Output: <tt class="COMMAND">cat</tt> and
<tt class="COMMAND">echo</tt></td>
<td width="34%" align="center" valign="top"><a href="file-commands.html"
accesskey="U">Up</a></td>
<td width="33%" align="right" valign="top">Copy and Move</td>
</tr>
</table>
</div>
</body>
</html>