Lesson1 Linux file common view commands cat, ls, more, less, head, touch

Linux Command Format command [options] [parameters].

Options usually "-" to guide a single character, a "-" boot multiple characters.

Single character options can be written together with the "-" boot.

View linux system manual available man + command names, see the help available commands + --help.

A, cat command:

1. from the first line displays the file contents:

cat file.txt

  

2. Read the data to a file:

从终端读入
cat > file.txt  

从文件中读入
cat a.txt b.txt > c.txt

3. Examples:

cat -n a.txt > b.txt

Two, ls command:

1. Common command options:

  •  -F file lists Flag, directory / * executable file, symbolic link to the file @, Trivial File no end tag.
  •  -a list all hidden files
  •  -l List File Details -> ls -l = ll
  •  -r Reverse Sort Order
  •  sort -t time (late arrival early)
  •  -u to the last file access time sorting
  •  -1 line shows only one file

 Share several operations 

 

 

 

 2. For more information about the file:

 first row

 1st character: - Representative regular file, b block device file, d directory file, c character device file, l symbolic link file, p file named pipe.

 2-4 characters: the file owner access, r read, w write, x execution

 5-7 characters: the same set of user access rights

 8-10 characters: other user access

 other

 Column 2: File link or number of subdirectories.

 Columns 3 and 4: The file name of the Lord and the group name.

 Column 5: file size, the directory is the directory table size, character length link to link, equipment lists major and minor number, the data length of the pipe duct are listed.

 Column 6: The file was last modified.

 Column 7: file name.

Third, the split-screen display file contents:

1.  more: 

 + N: n-th line is displayed from.

 -f: count the number of rows.

 -s: merge multiple lines into one line blank.

 + / Str: after the start of the display str.

 2.  less:

 -a: Displays the last page.

 -f: Force open the file.

 -N: display the line number.

 -s: Merge blank lines.

3.  head:

 head -n file: n display lines file header file.

4.  tail:

 tail -n file: file displays the last n lines of the file.

Four, touch:

1. Function: the file was last modified time set to the current time, but does not modify the content of the document.

2. Example: 

Published 45 original articles · won praise 30 · views 10000 +

Guess you like

Origin blog.csdn.net/sinat_40471574/article/details/104720048