Skip to content

Instantly share code, notes, and snippets.

@sjehutch
Created May 10, 2015 22:51
Show Gist options
  • Save sjehutch/de73ba4d837fcb1fc734 to your computer and use it in GitHub Desktop.
Save sjehutch/de73ba4d837fcb1fc734 to your computer and use it in GitHub Desktop.
push google docs jwa
#!/bin/sh
count="$( find /home/mobiquity/incoming -mindepth 1 -maxdepth 1 | wc -l )"
if [ $count -eq 0 ] ; then
echo "No new file"
exit 1
else
cd /home/mobiquity
/usr/local/bin/gsutil cp -c -L logs/`date '+%Y_%m_%d__%H_%M'`.csv -r incoming gs://jwa-10003-file-storage
cd logs
awk -vc="URL" -vd="https://storage.googleapis.com/jwa-10003-file-storage/" 'NR==1{$0=c","$0}NR!=1{$0=d","$0}1' `date '+%Y_%m_%d__%H_%M'`.csv > `date '+%Y_%m_%d__%H_%M'`_1.csv
awk -F, '{print $1 $2 "," $3 "," $4 ","$5}' `date '+%Y_%m_%d__%H_%M'`_1.csv > `date '+%Y_%m_%d__%H_%M'`_2.csv
awk '{gsub("gs://jwa-10003-file-storage/", "");print}' `date '+%Y_%m_%d__%H_%M'`_2.csv > `date '+%Y_%m_%d__%H_%M'`_3.csv
awk '{gsub("/file:/", "");print}' `date '+%Y_%m_%d__%H_%M'`_3.csv > `date '+%Y_%m_%d__%H_%M'`_4.csv
mv -v /home/mobiquity/incoming/* /home/mobiquity/processed
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment