awk
把文本中的换行替换成逗号,并保存到b.txt文件中
awk '{{printf"%s,",$0}}' a.txt > b.txt
去掉文本中的换行
awk '{printf("%s ",$0)}' file > renamefile
linux awk命令详解
https://www.cnblogs.com/xudong-bupt/p/3721210.html
https://www.cnblogs.com/moveofgod/p/3540575.html
去除文本中等号后面的值,然后在每个行尾加上等号
- 去除=号后面的区域 并写入application_no_equals.properties文件中
awk -F '=' '{print $1}' application.properties > application_no_equals.properties
- value后面增加等号,并且先判断$1是否为空
awk '{if($1!~/^$/)print $1"="}' application_no_equals.properties > application_equals.properties
把A和B文件中有相同ID的B文件的内容输出到文件C
awk 'NR==FNR{a[FNR]=$0} NR>FNR{for(i in a)if($0~a[i]){print;getline;print}}' A B >C
NR==FNR表示当前在处理文件A,读取文件A将内容放入数组a。
NR>FNR表示当前在处理文件B。
读取冒号后面内容
echo "test:this" | awk -F':' '{print $2}'