Linux 关于egrep命令
如何创建允许文件作为命令行参数并使用egrep命令在屏幕上打印长度超过12个字符的所有行的bash脚本?您可以使用: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 '.{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
?这不是这份工作的最佳工具。我需要学习这个工具,因为它是我的考试题目