Batch execution of statements from the command line under linux

The reason for doing this is not to be handsome, but to have actual needs. In work, it is unavoidable to operate on the server, however, the server generally does not have a graphical interface installed. At that time, I uploaded some database compressed packages remotely, which needed to be decompressed and then imported into the database. At that time, there were more than 200 compressed packages, and it was completely impossible to decompress them by manpower alone, so I searched for tutorials on the Internet, and finally got I figured it out. I like it. Let’s see my code in detail:
for i in $(ls *.tgz); do tar -zxvf $i;done

is actually a for in loop statement with ; separated, followed by do It is the executed statement block.

Similarly , after decompression, you can delete these compressed packages, the code is as follows:
for i in $(ls *.tgz);do rm -rf $i;done
All extensions can be . tgz files are deleted


Or : write a script a.sh

#!/bin/bash
echo $i
mysql bbs9 <$i
mv $i end/

and then type on the command line:
find ./ -name "*.sql" - exec ./a.sh" {}"\;

Execute batch import sql command

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326892450&siteId=291194637