$ gzip file.txt | aws s3 cp file.txt.gz s3://my_bucket/
I am trying to gzip file.txt to file.txt.gz and the passing it to aws program which has s3 as a command and cp as a subcommand.
Generates : warning: Skipping file file.txt.gz. File does not exist.
I'm newbie in linux. Can anyone help on this please?
Replace the
|
with&&
. The|
means pipe, which runs theaws
command immediately without waiting forgzip
to finish or even start. Also the|
will do nothing here, since its purpose is to send the stdout output ofgzip
to the stdin input ofaws
. There is no stdout output fromgzip
in that form.If you really want
gzip
to send its output to stdout and not write the filefile.txt.gz
, then you need to usegzip -c file.txt
. Then you need a way foraws
to take in that data. The typical way this is specified in Unix utilities is to replace the file name with-
. However I don't know ifgzip -c file.txt | aws s3 cp - s3://my_bucket/
will work.