[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Help with files and spaces with shell script



On 2007-09-16 17:43, Paul Ward wrote:
>> But pretending ctime is creation time, which may be close enough for
>> your purposes:
> You're right ctim eis not creation but is close enough for my script
> 
>>   find /myth/recordings/ -maxdepth 1 -name \*.mpg -ctime -1 ! -mtime -1 -print
> I did not know you could use the ! that saves one line of code ;o)
> 
> My script so far looks like this,can someone help me on one issue.
> 
> If a file name has a space then the script goes wrong as it interprets
> each word as a file, I thought that putting the variable into quotes
> would fix this but it did not, what is the answer please.
> 
> for i in `find /myth/recordings/ -maxdepth 1 -name \*.mpg -ctime -1 !
> -mmin -1 -print`
>  do
>    /usr/bin/mencoder "$i" -ovc xvid -oac mp3lame -xvidencopts
> bitrate=800 -o $TMP/tmp.mpg > $TPM/enc_errors 2>&1 && cp -fv
> $TMP/tmp.mpg "$i"
>  done

There were some interesting suggestions with setting IFS, but you can
also do it like this (if there are no newlines in the file names):

find /myth/recordings/ -maxdepth 1 -name \*.mpg -ctime -1 ! -mmin -1
-print | while read i; do
/usr/bin/mencoder "$i" -ovc xvid -oac mp3lame -xvidencopts bitrate=800
-o $TMP/tmp.mpg > $TPM/enc_errors 2>&1 && cp -fv $TMP/tmp.mpg "$i"
done

No need to change IFS.

-- 
Sjoerd Mullender


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]