Reading files in a directory using bash
The following code reads files in a directory called SQL. Then if runs an SQL command with the file name as input. Finally, it deletes the file from the directory.
#!/bin/bash for file in sql/* do echo "Processing $file\n" mysql -u root -pdonut node2 < $file rm -f $file done