AWS S3 with Bash Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AWS S3 with Bash Script
# 1  
Old 02-27-2015
AWS S3 with Bash Script

Hello All,

I am trying few stuff on Amazon S3 move files to EC2 (Ubuntu Server)

I am receiving daily 2 files in S# bucket

Code:
XYZ_2015-02-26_ 200.csv
ABC_2015-02-26_ 200.csv

I want to move daily received files to local EC2(Ubuntu server) and rename files to
Code:
XYZ_2015-02-26.csv
ABC_2015-02-26.csv

Instead of Renaming files after moving to EC2 , if possible i want to rename files on S3 itself.

and send an email notification with files received or not on daily basis

Is this possible using Bash? If yes, please guide.

Thanks
Krux
# 2  
Old 03-02-2015
If rename command is available..

Code:
rename _200.csv .csv *2015-02-26_200.csv

will turn them into

Code:
ABC_2015-02-26.csv
XYZ_2015-02-26.csv

# 3  
Old 03-02-2015
Quote:
Originally Posted by krux_rap
Hello All,

I am trying few stuff on Amazon S3 move files to EC2 (Ubuntu Server)

I am receiving daily 2 files in S# bucket

Code:
XYZ_2015-02-26_ 200.csv
ABC_2015-02-26_ 200.csv

I want to move daily received files to local EC2(Ubuntu server) and rename files to
Code:
XYZ_2015-02-26.csv
ABC_2015-02-26.csv

Instead of Renaming files after moving to EC2 , if possible i want to rename files on S3 itself.

and send an email notification with files received or not on daily basis

Is this possible using Bash? If yes, please guide.

Thanks
Krux
Hello Krux_rap,

Could you please try following.
Code:
ls -lhtr *200.csv | awk '{A=$(NF-1);gsub(/\_/,X,$(NF-1));print "mv " A $NF OFS $(NF-1)".csv"}'

It will print only the move command with new file and old file names, if happy with results you can try following.
Code:
ls -lhtr *200.csv | awk '{A=$(NF-1);gsub(/\_/,X,$(NF-1));print "mv " A $NF OFS $(NF-1)".csv"}' | sh

Thanks,
R. Singh
# 4  
Old 03-02-2015
If you have s3cmd, it has a 'move' commmand.
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

AWS Cloud EBS limit script!

Hi, I am trying to correct the following script to get total EBS usage from Amazon cloud. Can someone please help in correcting it. It appears that its not working properly. t=0; for i in `ec2-describe-volumes | grep VOLUME | grep standard | awk '{print $3}'`; do t=`expr $t + $i`; done;... (2 Replies)
Discussion started by: amar0000
2 Replies

3. Virtualization and Cloud Computing

How to grow an EBS Array at AWS

This process was collected by trial and error (mostly error) since most of the documents I found on the 'net were incomplete. The cookbook/walkthrough on how to grow an Array on EBS at AWS... # walkthrough by John Jones (jjones at cirrhus9 dot com) umount /dev/md0 mdadm --stop /dev/md0... (0 Replies)
Discussion started by: Habitual
0 Replies

4. Virtualization and Cloud Computing

Computing in the Clouds with AWS

Tim Bass 07-25-2008 02:34 AM The admin*team at The UNIX Forums*have been considering moving the UNIX and*Linux*Forums to the clouds - the Amazon Web Services (AWS) cloud.* Amazon EC2 is one option to scale the forums, which is a*LAMP application.* Amazon EC2 allows*us to rent dedicated... (3 Replies)
Discussion started by: Linux Bot
3 Replies
Login or Register to Ask a Question