combine.sh 668 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. # 用于将IDEA导出的不同表sql文件,整合成一份
  3. # Get the current date in the format yyyymmdd
  4. current_date=$(date +%Y%m%d)
  5. # Create the new file name
  6. new_file="agileboot-${current_date}.sql"
  7. # Check if the new file already exists
  8. if [[ -f "$new_file" ]]; then
  9. # Remove the existing file
  10. rm "$new_file"
  11. fi
  12. # Loop through all .sql files in the current directory
  13. for file in *.sql
  14. do
  15. # Replace '`agileboot`.' with an empty string and append the contents to the new file with a blank line after
  16. sed "s/\`agileboot-pure\`\./ /g" "$file" >> "$new_file"
  17. echo "" >> "$new_file"
  18. done
  19. echo "Concatenation complete. Output file: $new_file"