Linux basics-4day-Linux document operation command-(cp/touch/nl/rmdir/wc)

Linu the X- document operation command - ( cp / Touch / NL / rmdir / WC )

1. The cp command

Description: Copy files or directories.

Usage: cpt [parameter options] [source file/directory name] [destination file/directory name] 

parameter:

The main parameters

significance

-r

Recursively copy sub-files and sub-directories, generally used when copying directories

-a

Keep all attributes of the original document when copying

Eg:

[root@test ~]#cp ping.sh test.txt #copy ping.sh as test.txt

2, touch command

Description: The time when the file was created or modified.

Usage: touch [parameter option] [file name]

parameter:

parameter

significance

-a

--time=atime / --time=access / --time=use only change the access time

-d/-t

Use the specified time instead of the current time

-m

--time=mtime or --time=modify only change the change time.

-r

Set the date and time of the specified document or directory to be the same as the date and time of the reference document or directory.

-c

 Or --no-create, does not exist, do not create any document.

Eg:

[root@test ~]#touch ping.sh #Create ping.sh file 
[root@test ~]#touch -r ping.sh ping1.sh #Modify two timestamps to be the same 
[root@test ~]#touch -t 202002211933.22 ping.sh #Set the specified time

Note: -t specifies the time format: [[CC]YY]MMDDhhmm[.SS]     

CC is the first two digits in the year, that is, the "century";

YY is the last two digits of the year, that is, the year in a certain century;

MM is the number of months, DD is the number of days, hh is the number of hours (time), mm is the number of minutes, and SS is the number of seconds.

3. nl command

Description: Calculate the line number in the file and automatically add the line number to the output file content.

Usage: nl [parameter options] [file name]

parameter:

parameter

Features

-b a

Regardless of whether it is a blank line, the line number is the same as cat -n

-b t

Do not list blank line number (default)

-n ln

The line number is displayed on the far left of the screen

-n rn

The line number is displayed on the far right of the field without adding 0

-n rz

The line number is displayed on the far right of the field, add 0

Eg:

[root@test ~]#nl ping.sh #Add a line number to display the content of the ping.sh file 
[root@test ~]#nl -b a ping.sh #A blank line also adds a line number to display the ping.sh file

4. The rmdir command

Description: Delete empty directories

Usage: rmdir [parameter option] [directory]

parameter:

-p

Recursively delete empty directories

-v

--verbose show the result of the command execution

Eg1:

[root@test ~]#rmdir -p test #recursively delete empty directories in the test directory

5、wc命令

描述:显示文件行、单词、字节统计信息。

用法:wc  [参数选项] [文件名程]

参数:

-c

显示文件字节统计信息

-l

显示文件数统计信息

-w

显示文件单词统计信息

Eg:

[root@test ~]# wc -l ping.sh     #统计ping.sh文件行数。

个人公众号:

图片.png

 

 

 


Guess you like

Origin blog.51cto.com/13440764/2576742