欢迎光临散文网 会员登陆 & 注册

Linux常用命令: 内容查看

2023-03-06 21:32 作者:石城城  | 我要投稿

放心~被指到的人一定能学会的~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 



cat

打印和合并文件内容

tac

倒序打印和合并文件内容

less

交互式阅读文件,允许滚动和搜索

cut

从输入或文件中剪切字段

tail

显示文件末尾部分

grep

匹配输入文件内容

 

 

1. cat/tac

cat

Print and concatenate files.

打印和合并文件内容

• Print the contents of a file to the standard output(打印文件内容到屏幕):

• Concatenate several files into the target file(合并多个文件内容到目标文件中):

• Number all output lines(给输出内容加行号):

tac

Print and concatenate files in reverse (last line first).

倒序打印和合并文件内容

• Print the contents of file1 reversed to the standard output(倒序打印文件内容到屏幕):

• Print the contents of the standard input reversed to the standard output(倒序打印屏幕输出内容):

2. less

Open a file for interactive reading, allowing scrolling and search.

交互式阅读文件,允许滚动和搜索

• Open a file(打开文件):

• Page down / up(下翻页/上翻页):

• Go to end / start of file(去文件开始和结束):

• Forward search for a string (press n/N to go to next/previous match)(向前搜索字符串, 通过n/N下一个前一个切换):

• Follow the output of the currently opened file(动态显示文件输入新内容):

• Open the current file in an editor(在Vim打开当前文件):

• Exit(退出):

3. cut

Cut out fields from stdin or files.

从输入或文件中剪切字段

• Cut out the first sixteen characters of each line of the given files(将文件内容剪切显示前1到16个字符):

• Cut out the first sixteen characters of each line of stdin(将输入数据剪切显示前1到16个字符):

• Cut out everything from the 3rd character to the end of each line(每行从第三个字符开始剪切显示):

• Cut out the fifth field of each line, using a colon as a field delimiter (default delimiter is tab)(通过':'分割字段后,显示第5列, 默认通过tab分割):

• Cut out the 2nd and 10th fields of each line, using a semicolon as a delimiter(通过';'分割字段后,显示第5和第10列):

• Cut out the fields 3 through to the end of each line, using a space as a delimiter(通过' '分割字段后,显示第3列后的所有内容):

4. tail

Display the last part of a file..

显示文件末尾部分

• Show last 'num' lines in file(显示文件的后num行):

• Show all file since line 'num'(从第num行显示文件内容):

• Keep reading file until Ctrl + C(保持读取文件直到Ctrl C):

5. grep

Matches patterns in input text.

匹配输入文件内容

Supports simple patterns and regular expressions.

支持正则表达式

• Search for an exact string(查找文件中的某个字符串):

• Search in case-insensitive mode(查找是不区分大小写):

• Search recursively (ignoring non-text files) in current directory for an exact string(从指定位置匹配文件内容, 忽略非文本文件):

• Use extended regular expressions (supporting ?+{}() and |)(支持扩展正则):

• Print 3 lines of [C]ontext around, [B]efore, or [A]fter each match(打印匹配内容的前后三行/前三行/后三行):

• Print file name with the corresponding line number for each match(打印内容时带上文件名和行号):

• Use the standard input instead of a file(过滤输入内容):

• Invert match for excluding specific strings(过滤内容取反显示 -- 非):

 

自学笔记~

如果有错~

期待大佬指出~

感谢帮助提升~ 


Linux常用命令: 内容查看的评论 (共 条)

分享到微博请遵守国家法律