Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


here docs | 10 comments | Create New Account
Click here to return to the 'here docs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
here docs
Authored by: airdrummer on May 24, '07 11:24:09AM
to simplify creating scripts on the fly, bash has 'here docs'
http://tldp.org/LDP/abs/html/here-docs.html
so replace all the >>$SCRIPT lines with:

cat > $SCRIPT <<EOF
#!/bin/bash
#
COUNT=1
TARDIR=\""`echo $TARDIR|sed 's/ /\\ /'`"\"
FILENAME=\""`echo $FILENAME|sed 's/ /\\ /'`"\"
test -d \"\$TARDIR\"
if [ ! $? ]; then
echo Dir does not exist. Exiting..
exit 1
fi
FOLDERS=\`ls \"\$TARDIR\"\`
for i in \$FOLDERS; do
let COUNT++
done
mkdir \"\$TARDIR\"/\$COUNT
mv \"\$FILENAME\" \"\$TARDIR\"/\$COUNT
exit 0
EOF
chmod +x $SCRIPT

there may b issues with the escaped quotes...

[ Reply to This | # ]
here docs
Authored by: harrisj on May 24, '07 02:19:28PM

Hey, that is handy. Learn something new everyday :)



[ Reply to This | # ]