Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of creating files by linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you the method of linux to create files, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Linux to create a file method: 1, use the touch method, code for [touch yy..]; 2, use vi and vim, code for [vi test.txt]; 3, use [>, >], code for [> test.ini]; 4, use cp to create a file; 5, use cat to create a file.

How linux creates a file:

1 、 touch

1.1 create a file

Touch yyTest.ini

1.2 create two files at the same time

Touch test1.txt test2.txt

1.3 create files in batches (e.g. 2000 files)

Touch test {0001..2000} .txt

1.4 change the file yyTest.ini time to the current time (yyTest.ini already exists)

Touch yyTest.ini

2. Vi and vim

Vi test.txtvim touch.txt

3. Use >, > >

3.1 >

Directly overwrite the original file without any hint

3.2 > >

Append to the end of the original file and will not overwrite the contents of the original file

3.3 create an empty file directly with >

> test.ini

3.4 ls create a file (write the result to a file)

Ls > test.inils > > test.ini

3.5 grep create a file (write the result to a file)

Ps-ef | grep java > test.inips-ef | grep java > > test.ini

3.6 echo create a file (write the result to a file)

Echo $PATH > test.iniecho $PATH > > test.ini

4. Create a file using cp

A file is created as long as the target file is a new file. For more information on cp commands, please see this blog post: https://www.cnblogs.com/poloyy/p/12514389.html

5. Create a file using cat

5.1 simple use >, > >

Cat > test.inicat > > test.ini

In fact, you also use > and > >, but the difference is that after typing the above command, you will enter the editing mode of test.ini. You can enter the content you want to write directly, and finally press ctrl+z to exit the editing mode to save automatically.

5.2 cat combined with eof

Cat > > test.ini test.ini

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report