Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.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
如何使用shell脚本删除文本文件中以数字开头的行_Shell_Text - Fatal编程技术网

如何使用shell脚本删除文本文件中以数字开头的行

如何使用shell脚本删除文本文件中以数字开头的行,shell,text,Shell,Text,我想知道一种读取文件并删除所有以数字开头的文本行的好方法,即使用一些shell脚本[0-9]。提前谢谢 您可以使用以下内容: grep -v '^[0-9]' input-file > output-file 使用sed: sed '/^[0-9]/d' file > outfile 如果已使用GNU,则可以更新原始文件本身: sed -i '/^[0-9]/d' file

我想知道一种读取文件并删除所有以数字开头的文本行的好方法,即使用一些shell脚本[0-9]。提前谢谢

您可以使用以下内容:

grep -v '^[0-9]' input-file > output-file
使用sed:

sed '/^[0-9]/d' file > outfile
如果已使用GNU,则可以更新原始文件本身:

sed -i '/^[0-9]/d' file