I have to read data from some files and insert the data into different tables in a database. Is Unix shell script powerful enough to do the job?
Is it easy to do the job in shell script or should I go about doing this in Java?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the data you are trying to import is in a reasonable format — comma-delimited, for example — and your database server has reasonable command line utilities, this should be no problem. MySQL has the ‘mysqlimport’ command-line tool that will accept various arguments describing the format of the file:
Passing the data through perl/sed/awk one-liners can help with getting it in the proper format, and the shell script can easily handle prompting for filenames, handling arguments, etc.
Using the various command-line tools provided by Unix is the entire point of bash scripting. Perl, mysql, etc. are all part of that toolkit.