- 论坛徽章:
- 0
|
原帖由 ruifox 于 2007-2-27 09:03 发表
1、字符替换
perl -p -i -e "s/\.doc/\.docbak/g" *txt
2、删除第三行
for i in `ls *txt`
do
sed '3d' $i>$i.new
mv $i $i.old
mv $i.new $i
done
# sh mybatch.sh
删除第三不成功,出错:
sed: ls: No such file or directory
usage: mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source ... directory
usage: mv [-f | -i | -n] [-v] source target
mv [-f | -i | -n] [-v] source ... directory
这是内容:
# cat sh mybatch.sh
#!/bin/sh
for i in 'ls *.txt'
do
sed '3d' $i>$i.new
mv $i $i.old
mv $i.new $i
done |
|