Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.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
Linux 关于egrep命令_Linux_Bash_Scripting - Fatal编程技术网

Linux 关于egrep命令

Linux 关于egrep命令,linux,bash,scripting,Linux,Bash,Scripting,如何创建允许文件作为命令行参数并使用egrep命令在屏幕上打印长度超过12个字符的所有行的bash脚本?您可以使用: egrep '.{13}' 将匹配任何字符,{13}将其重复13次。您可以将其放入shell脚本中,如: #!/bin/sh # Make sure the user actually passed an argument. This is useful # because otherwise grep will try and read from stdin and han

如何创建允许文件作为命令行参数并使用egrep命令在屏幕上打印长度超过12个字符的所有行的bash脚本?

您可以使用:

egrep '.{13}'
将匹配任何字符,
{13}
将其重复13次。您可以将其放入shell脚本中,如:

#!/bin/sh

# Make sure the user actually passed an argument. This is useful
# because otherwise grep will try and read from stdin and hang forever
if [ -z "$1" ]; then
  echo "Filename needed"
  exit 1
fi

egrep '.{13}' "$1"
$1
引用第一个命令参数。您还可以使用
$2
$3
等,并且
$@
引用所有命令行参数(如果您想在多个文件上运行它,这很有用):

您可以使用:

egrep '.{13}'
将匹配任何字符,
{13}
将其重复13次。您可以将其放入shell脚本中,如:

#!/bin/sh

# Make sure the user actually passed an argument. This is useful
# because otherwise grep will try and read from stdin and hang forever
if [ -z "$1" ]; then
  echo "Filename needed"
  exit 1
fi

egrep '.{13}' "$1"
$1
引用第一个命令参数。您还可以使用
$2
$3
等,并且
$@
引用所有命令行参数(如果您想在多个文件上运行它,这很有用):


为什么要使用
egrep
?这不是这份工作的最佳工具。我需要学习这个工具,因为它是我的考试题目。为什么要使用
egrep
?这不是这份工作的最佳工具。我需要学习这个工具,因为它是我的考试题目