Chapter 9
Making Empty Files (Touch, New-Item)

9.1 Do This


Source 15: Linux/Mac OSX Exercise 9
  $ cd temp
  $ touch iamcool.txt
  $ ls
  iamcool.txt
  $


Source 16: Windows Exercise 9
  > cd temp
  > New-Item iamcool.txt -type file
  > ls
  
  
      Directory: C:\Users\zed\temp
  
  
  Mode                LastWriteTime     Length Name
  ----                -------------     ------ ----
  -a---        12/17/2011   9:03 AM            iamcool.txt
  
  
  >

9.2 You Learned This

You learned how to make an empty file. On Unix touch does this, and it also changes the times on the file. I rarely use it for anything other than making empty files. On Windows you don't have this command, so you learned how to use the New-Item command, which does the same thing but can also make new directories.

9.3 Do More

  1. Unix: Make a directory, change to it, and then make a file in it. Then change one level up and run the rmdir command in this directory. You should get an error. Try to understand why you got this error.
  2. Windows: Do the same thing, but you won't get an error. You'll get a prompt asking if you really want to remove the directory.


Online Video Course + PDF For $9

For the price of most other course's PDFs only, you can get the full PDF for this class and 2 videos demonstrating the whole book for both Unix/OSX Terminal and Windows PowerShell. The course is self-paced so you can go through it any time you want, as many times as you want.


Signup Now At Udemy.com For $9