Use of sed, awk, tr commands

sed command:

1、模糊匹配文件某行并替换内容
sed -i '/s/test1.*/要替换的内容/g' file.txt

awk command:

1、以:为分隔符输出第三列
cat abc:test:hello | awk -F ":" '{print $3}'

tr command (convert or delete characters in the file):

#awk获取第三列数据,tr去掉字符lo
cat abc:test:hello | awk -F ":" '{print $3}' | tr -d 'lo'

#awk获取第三列数据,tr转换小写字母为大写
cat abc:test:hello | awk -F ":" '{print $3}' | tr a-z A-Z

Guess you like

Origin blog.csdn.net/sun172270102/article/details/114895733