eg: script.sh
#! /bin/ksh
for file in *.log
do
echo rm $file
done
for file in *.log
do
echo rm $file
done
so when you run the script:
$ ./script.sh
rm 1.log
rm 2.log
rm 3.log
rm 1.log
rm 2.log
rm 3.log
it will not execute the rm command since we only use echo. in order to execute it, no need to delete the echo but simpy pipe ( | ) it to the shell:
$ ./script.sh | sh
will delete those 3 log files.
No comments:
Post a Comment