05,文本处理cat more less head tail sort uniq wc tr grep cut jion sed awk ok

文本处理cat more less head tail sort uniq grep cut jion sed awk

################################################

cat:concatenate files and print on the standard output 显示文件内容到标准输出(显示器)

-e:显示最后一个结尾的字符

-n:显示行编号

[[email protected] ~]# cat -n /etc/shells

1  /bin/sh

2  /bin/bash

3  /sbin/nologin

4  /bin/dash

5  /bin/tcsh

6  /bin/csh

[[email protected] ~]# cat -e /etc/shells

/bin/sh$

/bin/bash$

/sbin/nologin$

/bin/dash$

/bin/tcsh$

/bin/csh$

################################################

more less :多屏显示

head:显示头几行

tail:显示末尾几行

head:显示前几行

tail:显示后几行

-f:追加显示内容,此命令较为重要

[[email protected] ~]# head -2 /etc/shells

/bin/sh

/bin/bash

[[email protected] ~]# tail -2 /etc/shells

/bin/tcsh

/bin/csh

################################################

sort:排序升序

-n:以数字排序

-r:降序

-t:字段分割符

-k:排序后相同的只显示一次

-f:排序忽略字符大小写

[[email protected] /]# cat /tmp/t1.txt

1

11

2

3

4

5

6

21

324

默认ASCII排序

[[email protected] /]# sort /tmp/t1.txt

1

11

2

21

3

324

4

5

6

ASCII降序

[[email protected] /]# sort -r /tmp/t1.txt

6

5

4

324

3

21

2

11

1

数字降序

[[email protected] /]# sort -nr /tmp/t1.txt

324

21

11

6

5

4

3

2

1

数字升序

[[email protected] /]# sort -n /tmp/t1.txt

1

2

3

4

5

6

11

21

324

################################################

uniq:(略掉)报告相邻的重复的行

-c:显示文件中行重复的次数

-d:只显示重复的行

[[email protected] /]# cat /tmp/t1.txt

1

2

3

1

2

2

45

45

[[email protected] /]# uniq /tmp/t1.txt

1

2

3

1

2

45

[[email protected] /]# uniq -c /tmp/t1.txt

1 1

1 2

1 3

1 1

2 2

2 45

[[email protected] /]# uniq -d /tmp/t1.txt

2

45

################################################

wc: word count 统计文件中的行 单词数 字节数

-l:行

-m:单词

-c:字节

[[email protected] /]# wc /tmp/t1.txt

8  8 18 /tmp/t1.txt

################################################

字符处理命令

tr:字符转换或删除字符

-d:删除字符集出现的所有字符

[[email protected] /]# tr ‘ab‘ ‘AB‘

ab

AB

abc

ABc

aBC

ABC

[[email protected] /]# tr -d ‘ab‘

abcd

cd

adbc

dc

aabb

################################################

cut:remove sections from each line of files 显示文件指定字段

cut:显示文件指定字段

-d:指定字段分割符,默认空格

-f:指定要显示的字段

-f 1,3   -f 1-3

[[email protected] /]# cut -d : -f1 /etc/passwd | tail -1

jameszhan

################################################

grep 后续详解

################################################

################################################

jion较少使用略过

################################################

sed 后续详解

################################################

awk 后续详解

################################################

时间: 2024-08-06 05:56:45

05,文本处理cat more less head tail sort uniq wc tr grep cut jion sed awk ok的相关文章

linux基础篇07,linux文本处理cat more less head tail sort uniq grep cut jion sed awk

文本处理cat more less head tail sort uniq grep cut jion sed awk ################################################ cat:concatenate files and print on the standard output 显示文件内容到标准输出(显示器) -e:显示最后一个结尾的字符 -n:显示行编号 [[email protected] ~]# cat -n /etc/shells 1  

文本处理cat more less head tail sort uniq grep cut jion sed awk

################################################ cat:concatenate files and print on the standard output 显示文件内容到标准输出(显示器) -e:显示最后一个结尾的字符 -n:显示行编号 [[email protected] ~]# cat -n /etc/shells 1  /bin/sh 2  /bin/bash 3  /sbin/nologin 4  /bin/dash 5  /bin/t

linux cat,tac,more,less,head,tail,cut,sort,uniq,wc,tr命令的使用

cat:连接并显示,比如: [[email protected] ~]# cat /tmp/sort.test  111 324 567 324 890 890 567 abc 加上选项-n会显示行号: [[email protected] ~]# cat -n /tmp/sort.test      1111      2324      3567      4324      5890      6890      7567      8abc 加上-E选项会显示行尾符$:(linux中行尾

linux常用命令-文本处理cut,sort,uniq,wc,tr

cut:截取文本特定字段 NAME       cut - remove sections from each line of files -d, --delimiter=DELIM(指定字段分隔符,默认是空格) use DELIM instead of TAB for field delimiter -f, --fields=LIST(指定要显示的字段) select  only  these  fields;  also print any line that contains no del

find cat sed awk 简单组合使用

find:查找 // .表示当前目录:   /表示根目录:  | 管道符:  xargs表示将前面的搜索接口作为参数传递到后面的命令中:grep 过滤 // xxxx表示文件名 1.查找指定文件名的文件 find . -name xxxx    // 区分大小写 find . -iname xxxx   // 不区分大小写 2.查找当前目录中文件名后缀为 .json的所有文件 find . -type f -name '*.json' 3.查找当前目录下所有文件夹 find . -type d

Linux命令(五)文本处理cat、tac、more、less、head、tail

查看文本: cat: -n:显示行号 -E: tac: more: less: head: tail: -f:查看文件尾部不退出,等待显示后续追加至此文件的新内容 文本处理 cut: -d:指定分隔符(默认是空格) -f:指定要显示的字段 -f 1:显示第一个字段 -f 1,3:显示第一个和第三个字段 -f 1-3:显示第一个到第三个字段 join: sed: awk:

Linux file viewer command:cat, tac, more, less, tail, head

文本文件查看命令:cat, tac, more, less, tail, head, touch cat : 从第一行开始全部的文件内容 cat命令是Concatenate(连续)的简写,将整个文件的内容显示在屏幕上,所以cat命令存在一个问题,就是当整个文件内容比较多,超过屏幕尺寸时,我们就只能看到最后显示在屏幕上的内容,之前显示的结果根本来不及看到. cat:连接并显示文件的信息,是全部显示文件内的信息 -n:在显示的时候可以显示行号,这个行号只是显示出来,跟文件内容没有  关系 -E:显示

第七课 环境变量PATH,cp、mv及查看文档cat/more/less/head/tail命令

一.环境变量(PATH) echo $PATH 查看环境变量的目录 PATH=$PATH:/tmp/ (目录)给一个目录赋值环境变量: 让以上环境变量永久生效: 编辑 vi /etc/profile/ 把以上参数加入到文本的最后,退出:wq ,取消删掉就行了. 二.cp命令 格式:cp 源文件 目录文件拷贝目录: cp -r 源目录 目标目录 (cp 所有目录的时候一定要加上/)当目标目录已经存在的时候,它会把源目录放到目标目录下去. (知识点:!$ 上一条命令的最后一个参数) 三.mv命令如果

2.10 环境变量PATH 2.11 cp命令 2.12 mv命令 2.13 文档查看cat/more/less/head/tail

2.10 环境变量PATH 2.11 cp命令 2.12 mv命令 2.13 文档查看cat/more/less/head/tail 2.10 环境变量PATH 如果你的目录在这里面 那么你敲命令句不需要敲绝对路径 但是如果再打开一个终端, 怎么让永久生效呢 系统有一个文件,是可以让它开机 或者是每次打开终端 都回去加载命令的 cat 一下看下文件有没有加上 命令 再打开一个终端 也是可以的 如果先取消掉 就重新改下变量PATH 还可以把里面的命令删掉 vi /etc/profile 重新退出