编程知识 cdmana.com

How to view the file content in common linux commands?

  Linux There are many commands involved in the process of learning , And it's very important to do operation and maintenance and master all kinds of commands , So you know Linux How to view the contents of the file ? What are the common commands ?

  1. cat Start with the first line to display the contents of the file

   usage :

  cat -A amount to -vET Integration options for , You can list some special characters instead of spaces ;

  cat -b List line numbers , Line number display only for non blank lines , Blank line without line number ;

  cat -E Break the ending bytes $ Show it ;

  cat -n Print out the line number , There will be a line number along with the blank line , And -b Different options for ;

  cat -T take [tab] Press to ^I Show it ;

  cat -v List some special characters that can't be seen ;

  2. tac Show the contents of the file from the last line

   usage :

  tac -b Add a separator before the line, not at the end of the line ;

  tac -r Parse the separation flag as a regular expression ;

  tac -s Use the specified string instead of the newline as the separation flag ;

  3. nl According to the line Numbers

   usage :

  nl -b a Whether it's a blank line or not , All line numbers are listed ;

  nl -b t No blank lines ;

  nl -n ln The line number is shown at the far left of the screen ;

  nl -n rn The line number is displayed on the far right side of your field , And no more 0;

  nl -n rz The line number is displayed on the far right side of your field , And add 0;

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

  4. more Page by page display file content

   usage :

   stay more During the operation of the program , You can press the following key :

   Blank key (space): Represents page down ;

  Enter: Represents flipping down 『 a line 』;

  / String : In this display , Seek down 『 String 』 This keyword ;

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

  q: The representative leaves immediately more , Don't show the contents of this file again .

  b or [ctrl]-b: Turn back the page on behalf of , But this is only useful for files , Useless for pipeline .

  5. less And more similar , But compared to more What's better is , He can turn the page forward

   usage :

  less The commands that can be entered at run time are :

   Blank key : Page down ;

  [pagedown]: Page down ;

  [pageup]: Page up ;

  / String : Seek down 『 String 』 The function of ;

  ? String : Search up 『 String 』 The function of ;

  n: Repeat previous search ( And / or ? of !) ;

  N: Reverse repeat previous search ( And / or ? of !) ;

  q: Leave less This procedure ;

  6. head Show the first few lines

   grammar :

  head -n Followed by number , Represents the number of rows displayed ;

  7. tail Show the last few lines

   usage :

  tail -n Followed by number , Represents the number of rows displayed ;

  tail -f Indicates continuous detection of the following file name , Wait until you press [ctrl]-c It's over tail Detection of ;

版权声明
本文为[osc_ 4zx4bjhm]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201225122405123c.html

Scroll to Top