The directory called project1 will be given the new name project2 as long as a directory called project2 did not previously exist. When you type the command mv project1 project2 You can also use the mv command to rename and move directories. There will now be two copies of chapter1, one in the current directory and one in project1. Will place a copy of the file chapter1 in the directory project1, but leave chapter1 intact in the current directory. Will move the file bibliography into the directory project1. Assume that you want to place some files from your current directory into a newly created directory called project1. The mv and cp commands can be used to put files into a directory. Moving and Copying Files Into a Directory
#Unix make file executable windows how to#
For details on how to navigate directories and display the files and directories they contain, see List Contents and Navigate Unix Directories. The directory that you create will be a subdirectory within your current directory. The command mkdir project1Ĭreates a directory called project1, where you can store files related to a particular project. Type y or yes to remove a file type n or no to leave it intact.Ĭreating directories permits you to organize your files. You will be prompted to confirm whether you really want to remove the files: rm: remove firstfile (y/n)? y You may remove more than one file at a time by specifying a list of files to be deleted. For example, rm file3ĭeletes file3 and its contents. As a result, fourthfile is renamed secondfile, but in the process secondfile is deleted. Mv will remove the original contents of secondfile and replace them with the contents of fourthfile. For example, if you have two files, fourthfile and secondfile, and you type the command mv fourthfile secondfile Like cp, the mv command also overwrites existing files. This command results in the complete removal of thirdfile, but a new file called file3 contains the previous contents of thirdfile. To change the name of a file, use the following command format (where thirdfile and file3 are sample file names): mv thirdfile file3 Instead, the mv command is used both to change the name of a file and to move a file into a different directory.
Unix does not have a command specifically for renaming files. You will find that the original contents of firstfile are gone, replaced by the contents of thirdfile. If you create a different file called thirdfile and then type the following command: cp thirdfile firstfile The cp command works by overwriting information. This results in two files with different names, each containing the same information. For example, to create an exact copy of the file called firstfile, you would type: cp firstfile secondfile To make a duplicate copy of a file, use the command cp. To examine the contents of a file you have just created, enter this at the % prompt: cat firstfile (Hold down the Control key and type d.) On your screen, you will see: % cat > firstfile Terminate file entry by typing Control-d on a line by itself. To create a practice file (called firstfile) and enter one line of text in it, type the following at the % prompt: cat > firstfile
Many people create files using a text editor, but you can use the command cat to create files without using/learning to use a text editor. Each of these is a unique file: myfile, Myfile, myFile, and MYFILE. It is best to avoid using these characters in file names: / \ " ' * | ! ? ~ $ Some characters have special meanings to Unix. You can divide a multi-word file name using either an underscore or a period (for example, chapter_one or chapter.two). Names may use almost any character (except a space). A directory may have the same name as one of the items it contains.įile and directory names may be up to 256 characters long. Within a directory, each item (that is, each file or directory) must have a unique name, but items with the same name may exist in more than one directory.
#Unix make file executable windows windows#
Directories are analogous to Macintosh and Windows folders.Įach file and directory has a name. Directories may contain files and/or other directories. Unix makes no distinction among file types-a file may contain the text of a document, data for a program or the program itself.ĭirectories provide a way to organize files, allowing you to group related files together. What Are Unix Files and Directories?Ī file is a "container" for data. The instructions here apply to many other Unix machines however, you may notice different behavior if you are not using the ITS Login Service. It assumes you are using Unix on the ITS Login Service (). This document lists commands for creating, copying, renaming and removing Unix files and directories.