Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 May 2006 10:27:22 +0200
From:      Kyrre Nygard <kyrreny@broadpark.no>
To:        Atom Powers <atom.powers@gmail.com>
Cc:        questions@freebsd.org
Subject:   Re: Some shell scripts; a more elegant approach?
Message-ID:  <7.0.1.0.2.20060518102146.021fa540@broadpark.no>
In-Reply-To: <df9ac37c0605160859q6b8376e1saca51f2cf3504645@mail.gmail.co m>
References:  <7.0.1.0.2.20060516105228.02238068@broadpark.no> <df9ac37c0605160859q6b8376e1saca51f2cf3504645@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7.0.1.0.2.20060518102146.021fa540>