-2

I want to copy file from S3 bucket and I need to append the file to another file. I want to done in single command. aws s3 cp s3://sample/test.txt /home/user/test.txt this command is overwriting the existing file. If i use "cat >>" it was giving error. TIA.

Srinivas R
  • 335
  • 1
  • 3
  • 8
  • You can't with just shell commands. Why does it have to be a single command? – stdunbar Jun 27 '18 at 22:46
  • Write the two commands in a shell script and execute that as one command, or run both commands on the same command line e.g. cmd1;cmd2 or cmd1 && cmd2. – jarmod Jun 27 '18 at 23:37

1 Answers1

5

You can copy to standard output:

aws s3 cp s3://my-bucket/foo.txt -

Therefore, you could append it to a file:

aws s3 cp s3://my-bucket/foo.txt - >>appended_file

See: Downloading an S3 object as a local file stream at the bottom of: cp — AWS CLI Command Reference

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470