Some shell scripts; a more elegant approach?
Kyrre Nygard
kyrreny at broadpark.no
Thu May 18 01:27:23 PDT 2006
At 17:59 16.05.2006, Atom Powers wrote:
>It is difficult to understand exactly what you want your script to do
>without comments. You may get a better response if you can describe
>what you want your scripts to do.
Thanks man, your advice was really helpful!
This though:
--
for file in `find -s . -type f -name "*.txt"`; do
# This removes CRLF, double or more empty lines
# as well as trailing whitespace.
#
tr -d '\r' < $file | cat -s | sed -E -e
's/[[:space:]]+$//' > $file.tmp
# Creates file blank containing an empty line
#
echo > blank
# Add an empty line to the end of $file.tmp
#
echo >> $file.tmp
# $file now starts with an empty line too
#
cat blank $file.tmp >> $file
rm -f blank $file.tmp
done
for file in `find . -type f -name "*.txt" -size -300c`; do
echo "$file: Corrupt"
done
--
I'd like to incorporate the 2nd for loop into the first somehow.
That last find command finds files that are below 300 bytes.
Now I'm sure there's a better way of doing that.
Thanks Atom Powers! :)
Take care,
Kyrre
More information about the freebsd-questions
mailing list