Linux 删除输出文件中的字母
我将以下文本作为linux中的输出:Linux 删除输出文件中的字母,linux,shell,output,Linux,Shell,Output,我将以下文本作为linux中的输出: service {'name': 'services'} enable yes frequency 7200 service {'name': 'files'} enable yes frequency 6000 none 我正在寻找将输出转换为以下格式的方法: services yes 7200 files yes 6000 services yes 7200 files yes 6000 Im
service {'name': 'services'}
enable yes
frequency 7200
service {'name': 'files'}
enable yes
frequency 6000
none
我正在寻找将输出转换为以下格式的方法:
services yes 7200
files yes 6000
services yes 7200
files yes 6000
Im使用下一个命令:
| xargs -n 7 | awk '{print $3 " / " $5" / " $7}'
但作为输出,我有:
services} / yes / 7200
files} / yes / 6000
是否要删除该},或获取没有此字符的最后输出 如果您可以删除任何和所有'},最简单的方法是使用translate:
| xargs -n 7 | awk '{print $3 " / " $5" / " $7}'| tr -d '{'
tr-d将删除“{”的每个实例如果您可以删除任何和所有“}”,最简单的方法是使用translate:
| xargs -n 7 | awk '{print $3 " / " $5" / " $7}'| tr -d '{'
tr-d将删除“{”的每个实例。如果将字段分隔符设置为除字母和数字以外的任何字符,它将简化解析:
awk -F'[^a-z0-9]+' '
/service/ {printf "%s ", $3}
/enable/ {printf "%s ", $2}
/frequency/ {print $2}
' /tmp/test-data
输出:
如果将字段分隔符设置为除字母和数字以外的任何字符,则可以简化解析:
awk -F'[^a-z0-9]+' '
/service/ {printf "%s ", $3}
/enable/ {printf "%s ", $2}
/frequency/ {print $2}
' /tmp/test-data
输出: