Created
November 10, 2012 10:59
-
-
Save songpp/4050728 to your computer and use it in GitHub Desktop.
tree2sql.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /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