搜尋根目錄底下*.c內含有test字樣的檔案
grep所接的參數為"test"空白{}空白\;
寫成bash檔,來使用
findkey.sh
#!/bin/bash
if [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" == "--h" ] || [ "$1" == "--H" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then
echo "findkey path filename keyword"
else
sudo find $1 -name $2 -exec grep -H $3 {} \;
echo "---THE END---"
fi
exit 0
findfile.sh
#!/bin/bash
if [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" == "--h" ] || [ "$1" == "--H" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then
echo "findfile path filename"
else
sudo find $1 -name $2
echo "---THE END---"
fi
exit 0
寫成bash檔,來使用
findkey.sh
#!/bin/bash
if [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" == "--h" ] || [ "$1" == "--H" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then
echo "findkey path filename keyword"
else
sudo find $1 -name $2 -exec grep -H $3 {} \;
echo "---THE END---"
fi
exit 0
findfile.sh
#!/bin/bash
if [ "$1" = "-h" ] || [ "$1" = "-H" ] || [ "$1" == "--h" ] || [ "$1" == "--H" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then
echo "findfile path filename"
else
sudo find $1 -name $2
echo "---THE END---"
fi
exit 0
沒有留言:
張貼留言