Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在BASH中删除只包含数字的行?_Bash - Fatal编程技术网

如何在BASH中删除只包含数字的行?

如何在BASH中删除只包含数字的行?,bash,Bash,我有一个TXT文件。如何仅删除仅包含数字的行。例如: This has some text. 1300 This has some more text. 1210 This has a text and some numbers. 12 在上面的示例中,只有第2行和第4行会被删除,因为它们除了数字之外不包含其他符号。使用grep: grep -v -E '^[0-9]+$' < source.txt > destination.txt grep-v-E'^[0-9]+$'dest

我有一个TXT文件。如何仅删除仅包含数字的行。例如:

This has some text.
1300
This has some more text.
1210
This has a text and some numbers. 12
在上面的示例中,只有第2行和第4行会被删除,因为它们除了数字之外不包含其他符号。

使用grep:

grep -v -E '^[0-9]+$' < source.txt > destination.txt
grep-v-E'^[0-9]+$'destination.txt

以下是一个awk解决方案:

awk '! /^[0-9]+$/' input.txt
Sed解决方案(将覆盖该文件):


sed-i-e'/^[0-9][0-9]*$/d'文件到munge
sed -i '/^[[:digit:]]*$/d' filename.TXT