The situation:
I want to copy all odt files with size greater than 0 from one folder into another. Filenames will contain the following characters: + % & [ ( and spaces.
Here is my attempt:
#!/bin/bash
mvfunc ()
{
if [ -s "$1" ]; then
cp -n "$1" /home/telas/zztmp/currentfiles/
/usr/bin/truncate -s 0 "$1"
return 0
fi
}
fileslist=$(ls --quoting-style=shell-always /home/telas/zzz/workingfiles/*.odt)
for filename in "$fileslist" ; do
mvfunc "$filename"
done
All help is very much appreciated!!
for file in *.odt
directly instead of parsingls
. – frostschutz Mar 19 '16 at 12:22odtList=(*.odt); for f in "${odtList[@]}"; do myfunc "$f"; done
would be closer to your solution – Valentin Bajrami Mar 19 '16 at 12:24