1

I have almost thousand of files with .dat extension And I am using a tool built in go to upload it, But There is an issue as my each file is 31 GB and there a lot, So I want to make a bash script for doing this, which may work like

root@Ubuntu-1404-trusty-64-minimal /storage # gdrive --config "config.json" upload 7.dat
Uploading 7.dat
Uploaded 0B8RgYtlwEE1sSzJxeEhKd19PWnM at 17.7 MB/s, total 31.5 GB

But It need monitoring after each upload, I need to set next upload. Is there possible in any bash linux script, Which may wait for the process to be complete? and the automatically start for the next .dat file?

1 Answer 1

0
#!/bin/bash

for f in *.dat
do
    gdrive --config "config.json" upload $f
done

Or a bash one-liner:

[mehlsec@localhost ~]$ for f in *.dat; do gdrive --config "config.json" upload $f; done

These will upload all .dat files in your current directory one after the other.

3
  • how to run this? May 25, 2017 at 12:43
  • Just add that code into a file named something.sh, then make it executable with the command chmod +x something.sh. Run the script with ./something.sh while in the directory with all the .dat files.
    – mehlj
    May 25, 2017 at 13:33
  • Or if you want a bash one-liner: for f in *.dat; do gdrive --config "config.json" upload $f; done
    – mehlj
    May 25, 2017 at 13:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.