linux based operation and maintenance [linux common commands] Command File ------ [touch, cat, tac, more, less, head, tail]

1.touch

  • Command name: touch
  • The path then the command: / bin / touch
  • Execute permissions: All users
  • Description: Create an empty file
touch [文件名]

useCreate an empty file touch

Plus the file name directly

Here Insert Picture Description
Absolute path to the file name

Here Insert Picture Description

2.cat

  • Command name: cat
  • The path then the command: / bin / cat
  • Execute permissions: All users
  • Description: The file contents
cat [-n] [文件名]

You can not open the file, view the file contents directly. To ensure that no changes to the contents of the file after we read the contents of the file.

Here Insert Picture Description

2.1 -n

When you can view filesAdd line numbersTo prevent errors.

Here Insert Picture Description

3.tac

  • Command name: tac
  • Command then the path: / usr / bin / tac
  • Execute permissions: All users
  • Description: The file contents (reverse display)
tac [文件名]

The documents show the tail to the head

Here Insert Picture Description
tac command without the -n parameter a

4.more

  • Command name: more
  • The path then the command: / bin / more
  • Execute permissions: All users
  • Description: page display file contents
more [文件名]

If aExcessive content of the document is too longWe order not to miss the content, usemore command to view the page

Here Insert Picture Description
Here Insert Picture Description
You can use the followingOptionsoperating:

  • (Spaces) or f: page
  • (Enter): Wrap
  • q or Q: quit

Note : more command displays the contents,Can only be turned down, not like the turn

5.less

  • Command name: less
  • Command then the path: / usr / bin / less
  • Execute permissions: All users
  • Description: page display file contents (available page up)
less [文件名]

This command is compared with the moreThere are page-up function

Here Insert Picture Description

Here Insert Picture Description
You can use the followingOptionsoperating:

  • (Space) or f: Down
  • PgUp: Page Up
  • (Arrow): up linefeed
  • (The Enter) or (down arrow): Down linefeed

Note : You can alsoQueries specific content

/service[关键内容]

Here Insert Picture Description
You can use the followingOptionssearch for:

  • n: next match downwardly

Note : less exit no marks on the character device.

6.head

  • Command name: head
  • Command then the path: / usr / bin / head
  • Execute permissions: All users
  • Description: display the first few lines of the file
head [-n] [文件名]

can useDigital parameter -n +A few lines before, decided to see if that is not followed by -nDefault View first 10 rows

Here Insert Picture DescriptionDisplays the first 5 lines

Here Insert Picture Description

7.tail

  • Command name: tail
  • Command then the path: / usr / bin / tail
  • Execute permissions: All users
  • After the show a few lines of the file: Functional Description
tail [-n/-f] [文件名]

Back from the front display articleAfter a few lines specified, Without -n10 default Line

Here Insert Picture Description
After 5 lines

Here Insert Picture Description
Note : tail can dynamically update the end of the content of the article, as a kind of file can monitor.

Here Insert Picture Description
After we open a new terminal, new content written to the file, the file will automatically find tail 10 lines with the new.
Here Insert Picture Description

Published 10 original articles · won praise 0 · Views 241

Guess you like

Origin blog.csdn.net/mango_kid/article/details/104736362