Viewed k times. Improve this question. Scarabee 5, 5 5 gold badges 26 26 silver badges 51 51 bronze badges. Can you clarify what "If the file exists also it should create a new file" means? A new file with a composed name? Add a comment. Active Oldest Votes. Improve this answer. Meaning it will empty it in case already exists. The command is lowercase: touch filename. Edit this Article. We use cookies to make wikiHow great.
By using our site, you agree to our cookie policy. Cookie Settings. Learn why people trust wikiHow. Download Article Explore this Article methods. Related Articles. Article Summary. Method 1. If not, log into the system on which you want to create a file through the console. Use cd to change to the desired directory. If you're already in the directory where you'd like to create the file you can skip this step.
Replace newfilename with the desired file name. This creates a new blank file with that name in the current directory. Method 2. Replace newfilename with whatever you'd like to call your new file. This opens a new blank line.
Type some text. Anything you type here will be added to the file. You'll need to be on a blank line to finish the cat command. This saves the file to the current directory with the name you entered. Method 3. You'll want to be in the directory where you'd like to store your new file before opening the text editor.
This opens the Vi or Vim, depending on the version of Unix you're using text editor. To edit a specific text file with Vi, type vi filename' instead. Press i to enter input mode. Vi has two modes—insert mode and command mode. You must be in input mode to type text into the new file. Type some text optional. Press Enter. Did this summary help you? Yes No. Log in Social login does not work in incognito and private browsers.
Please log in with your username or email to continue. No account yet? Create an account. Edit this Article. We use cookies to make wikiHow great. By using our site, you agree to our cookie policy. Cookie Settings. Learn why people trust wikiHow. Download Article Explore this Article methods. Related Articles. Article Summary. Method 1. If not, log into the system on which you want to create a file through the console. Use cd to change to the desired directory. If you're already in the directory where you'd like to create the file you can skip this step.
Replace newfilename with the desired file name. This creates a new blank file with that name in the current directory. Method 2. Replace newfilename with whatever you'd like to call your new file. This opens a new blank line. Type some text. Anything you type here will be added to the file. You'll need to be on a blank line to finish the cat command. This saves the file to the current directory with the name you entered.
Method 3.
0コメント