There are 5 ways to write files in Linux, which are: 1. Create a file through the touch command; 2. Create a file using the vi and vim commands; 3. Use ">" and ">> " symbol to create a file; 4. Use the cp command to create a file; 5. Use cat to create a file.
#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
5 ways to create files in Linux
1. touch
1.1 Create one file
<p>touch yyTest.ini<br></p>
1.2 Create two at the same time File
<p>touch test1.txt test2.txt<br></p>
1.3 Create files in batches (such as creating 2000 files)
<p>touch test{0001..2000}.txt<br></p>
1.4 Change the file yyTest.ini time to the current time (yyTest.ini already exists)
<p>touch yyTest.ini<br></p>
2. vi and vim
<p>vi test.txt<br>vim touch.txt<br></p>
3. Use >, >>
##3.1 > to directly overwrite the original file without any prompt3.2 >>Append to the end of the original file and will not overwrite the content of the original file 3.3 Directly use > to create an empty file
<p>> test.ini<br></p>
<p>ls > test.ini<br>ls >> test.ini<br></p>
<p>ps -ef | grep java >test.ini<br>ps -ef | grep java >>test.ini<br></p>
<p>echo $PATH > test.ini<br>echo $PATH >> test.ini<br></p>
<p>cat > test.ini<br>cat >> test.ini<br></p>
<p>cat >> test.ini <<eof<br/>2<br/>2<br/>2<br/>eof<br/></p>
<p>cat >> test.ini <<exit<br>1<br>1<br>exit<br></p>
Linux Video Tutorial"
The above is the detailed content of There are several ways to write files in Linux. For more information, please follow other related articles on the PHP Chinese website!