这个脚本将以一个特定的模式来搜索一个目录中的每个文件,然后删除该模式匹配的记录。
代码:
#!/bin/sh
(责任编辑:IT)# This script will search every file in a directory for a # specific pattern and will delete the records that # matches with that pattern directory=$1 pattern=$2 for FILE in `ls $directory` do echo "$FILE" FILPATH="$directory"/"$FILE" sed ''/$pattern/'d' $FILPATH > "$directory/$FILE.new" done |