Skip to content

Instantly share code, notes, and snippets.

@songpp
Created November 10, 2012 10:59
Show Gist options
  • Select an option

  • Save songpp/4050728 to your computer and use it in GitHub Desktop.

Select an option

Save songpp/4050728 to your computer and use it in GitHub Desktop.
tree2sql.sh
#! /bin/sh
usage(){
echo "tree.sh <need generate dir> <target dir>"
echo "use absolute path"
}
if [ $# != 2 ]
then
usage
exit 1
fi
cd $1
TARGET_SQL_FILE="$2/inserts.sql"
for d in `ls`
do
echo "-- begin company code $d" >> $TARGET_SQL_FILE
if [ -d $d ]
then
for c in `ls $d`
do
if test
echo "insert into cms_attach_files(company, filename) values ( '$d' ,'$c' );" >> $TARGET_SQL_FILE
done
fi
echo "-- end company code $d \n" >> $TARGET_SQL_FILE
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment