如何从文件中删除特定模式

时间:2017-02-01 06:20:31

标签: bash sed grep

file.log:

This is a firstfile.c.txt: 234
This is a secondfile.cpp.txt: 456
welcome to scriptfile.h.txt: 999

输出:

This is a firstfile.c: 234
This is a secondfile.cpp: 456
welcome to scriptfile.h: 999

有人可以帮我从输入文件中删除.txt并显示上面的输出吗?

1 个答案:

答案 0 :(得分:0)

cat file.log | sed 's/\.txt:/:/'

sed 's/\.txt:/:/' file.log