Commonly used Linux file content viewing commands for Linux learning!

  As we all know, various commands are involved when learning Linux, so do you know what are the commonly used commands for viewing the contents of Linux files? I will summarize it for you.

  1. cat displays the contents of the file starting from the first line

  usage:

  cat -A is equivalent to the integration option of -vET, which can list some special characters instead of blanks;

  cat -b lists line numbers, only displays line numbers for non-blank lines, blank lines are not marked with line numbers;

  cat -E displays the ending line-breaking byte $;

  cat -n prints the line number, together with the blank line will also have the line number, which is different from the -b option;

  cat -T displays the [tab] key as ^I;

  cat -v lists some invisible special characters;

  2. tac displays the contents of the file starting from the last line

  tac -b adds a separator before the line instead of at the end;

  tac -r treats the separation flag as a regular expression to parse;

  tac -s uses the specified string to replace the line as the delimiter;

  3. nl display line number

  nl -ba lists the line number regardless of whether it is a blank line;

  nl -bt blank lines do not list line numbers;

  nl -n ln line number is displayed on the far left of the screen;

  nl -n rn The line number is displayed on the far right of its own field, and 0 is not added;

  The nl -n rz line number is displayed on the far right of its field, and 0 is added;

  nl -w The number of digits occupied by the row number field;

  4. more display file content page by page

  During the running of the more program, you can press the following keys:

  Space key (space): represents turning down one page;

  Enter: Turn down "one line";

  /String: It means to search down the keyword "string" in the displayed content;

  :f: display the file name and the number of lines currently displayed immediately;

  q: It means to leave more immediately and no longer display the content of the file.

  b or [ctrl]-b: means to turn back pages, but this action is only useful for files, not for pipelines.

  5. Less is similar to more, but better than more, it can turn the page forward

  The commands you can enter when less is running are:

  Space key: scroll down one page;

  [pagedown]: Scroll down one page;

  [pageup]: Turn one page up;

  /String: Search down "string" function;

  ? String: Search "string" upwards;

  n: Repeat the previous search (related to / or ?!);

  N: Reverse the previous search (related to / or ?!);

  q: leave the less program;

  6. head shows the first few lines

  grammar:

  head -n followed by a number, represents the number of rows;

  7. tail displays the last few lines

  tail -n followed by a number, represents the number of lines displayed;

  tail -f means to continuously detect the file name that is followed by the tail, and the tail detection will not end until you press [ctrl]-c.

Guess you like

Origin blog.51cto.com/15052541/2596866