我只需要删除以数字结尾的行(在文本文件中)。
之前:
1987 Robocop
1990 Robocop 2
1993 Robocop 3
2014 Robocop
之后:
1987 Robocop
2014 Robocop
最佳答案
既然你引用了我的 favorite movie ,我来回答:
sed '/[ \t][0-9][0-9]*[ \t]*$/d' movies.txt
这意味着:
Delete any line where there is either a space or a tab, followed by at least one digit, then any amount of spaces or tabs at the end of a line.
在 Linux 上有更紧凑的方法来表示这一点,但为了可移植性,我给了您一种比较困难的方法。
关于linux - Bash - 删除以数字结尾的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32318537/