R**g 发帖数: 59 | 1 怎么把一个目录下的所有文件的前3行删除?
谢谢! |
t*********l 发帖数: 30 | 2 #!/bin/sh
for file
do
mv ${file} ${file}.tmp
sed -e '1,3d' > ${file}
rm ${file}.tmp
done
save this file and then run
sh
【在 R**g 的大作中提到】 : 怎么把一个目录下的所有文件的前3行删除? : 谢谢!
|
a***n 发帖数: 262 | 3 #!/bin/sh -xv
#To get little hints please delete -xv flags
#remove first three lines of everyfile in current directory
#except the shell program
for file in `ls`
do
if ( test -f $file && test $file != `basename $0` )
then
sed 1,3d $file > $file.tmp
mv $file.tmp $file
else
echo "$0: $file can't be changed" 1>&2
fi
done
【在 R**g 的大作中提到】 : 怎么把一个目录下的所有文件的前3行删除? : 谢谢!
|
R**g 发帖数: 59 | 4 thank you very much. It really saves me lots of time.
【在 a***n 的大作中提到】 : #!/bin/sh -xv : #To get little hints please delete -xv flags : #remove first three lines of everyfile in current directory : #except the shell program : for file in `ls` : do : if ( test -f $file && test $file != `basename $0` ) : then : sed 1,3d $file > $file.tmp : mv $file.tmp $file
|