0
我正在使用bash脚本来grep文件,然后运行perl命令。我知道这些命令自从我使用它们以来就工作了,但我似乎无法让它们为bash脚本工作。我将不胜感激任何帮助。bash脚本+ grep + perl命令
当我输出$ 1等等它有值,但是当我输出grep命令与他们在里面。我得到的文件找不到或空白的空格。
#! /bin/bash
usage()
{
echo "Usage: $0"
echo $'\a'Supply 4 arguments
echo $0 arg1 arg2 arg3 arg4
echo "1. search parameters for bookmarks"
echo "2. What file to grep"
echo "3. file to temporaly store results"
echo "4. what file to store the final version"
exit 1
}
main()
{
# if [ "$#" -lt "4" ]
# then
# usage
# else
echo "beginning grep"
grep -ir "$1" "$2" >> "$3"
echo "grep complete"
# echo "beginning perl command"
# perl -0ne 'print "$2\n$1\n" while (/a href=\"(.*?)\">(.*?)<\/a>/igs)' "$3" >> "$4"
# echo "perl command complete"
# echo "done"
# exit 1
# fi
}
main
echo $0
echo $1
echo $2
echo $3
echo $4