编写脚本以在文件中搜索模式并输出在该文件中找到的行以及每行的编号。
我有脚本
#!/bin/bash
echo "------ File =" $2 "------"
grep -ne $1 $2
它工作得很好,但现在我需要验证。我想要的只是怎么写
if [[ number of arguments <2 ]]; then
echo "Must enter two arguments"
还有一些事情
if [[ $2 is not a file/directory]]; then
echo "second arguemnt needs to be a file/directory"
一如既往,非常爱。