Viewers: in countries Watching now:
Unix for Mac OS X Users unlocks the powerful capabilities of Unix that underlie Mac OS X, teaching how to use command-line syntax to perform common tasks such as file management, data entry, and text manipulation. The course teaches Unix from the ground up, starting with the basics of the command line and graduating to powerful, advanced tools like grep, sed, and xargs. The course shows how to enter commands in Terminal to create, move, copy, and delete files and folders; change file ownership and permissions; view and stop command and application processes; find and edit data within files; and use command-line shortcuts to speed up workflow. Exercise files accompany the course.
Now that we understand about file naming, we are actually ready to start creating some files and there are three main ways to create files in Unix. The first is using a text editor and Unix has its own text editor. We are not going to be using the text editors that you have on your Mac like Microsoft Word or whatever it might be. We are going to be using Unix's text editors and we are going to see how to do that in the next movie. There is also a technique where we can direct output from a command and put that in a file and we will see that in a future chapter. Then there is the simplest of all, the one that we are going to look at right now, which is just touch.
Let's go back to our command line and see how the touch command works. Back in my home directory, we can just see what's in there right now, ls -la. We will see the full list. Before we do touch, let's take a look at what touch actually does. Let's look in the manual for touch. Change file access and modification times. Well that doesn't sound like it has anything to do with creating files. But here is the thing. touch is a very simple command that Unix users use all the time and what it does is it just reaches out to a file and if it exists it touches it and updates its access time.
If it doesn't exist, it creates it for us and it's that second part that is what I want us to see. So let's just do touch somefile.txt and now let's do a listing again and there it is. It's the last one there. It's a zero file. There is nothing inside of it. You can see that the size of the file here. All I did was reach out and say, "Oh you want me to touch that file? Well it doesn't exist. I will create it for you." Now the other way of using touch would just be to say, let's say, touch .bash_history and see my history file right there. You can see the last access time for it was 15:59.
I will touch the bash_history and then let's go up, ls -la, now we can see that the time has been updated. Now it's 16:12. Now let me be the more conventional way of using touch, but the thing is that Unix users use touch to create files all the time. It's a really, really simple thing to do. You want to make sure that the file exists, so you touch it. If it exists already, fine. It's just going to update its access time and it's there, but if not, it will create it for us so that we can be assured that that file is there whenever we do a future operation.
So just keep it in mind as one of the tools. Now the file it creates is empty and in most cases what's more useful is actually to be able to put content in the file. So for that we are going to need to use a text editor.
Find answers to the most frequently asked questions about Unix for Mac OS X Users .
Here are the FAQs that matched your search "" :
Sorry, there are no matches for your search "" —to search again, type in another word or phrase and click search.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.