简体   繁体   中英

Grep AWS S3 command output

When running: aws s3 cp command to upload a file from local to S3 it shows the following output:

upload: ./test.txt to s3://demo-bucket/test.txt

How do I extract only s3://demo-bucket/test.txt string from the command output using grep ?

You can pipe the command to as follows:

grep -o 's3:\/\/.*$'
#s3://demo-bucket/test.txt

Note the usage of the -o flag, which tells to only return the matched string.


You may also consider piping to :

awk '{print $4}'
#s3://demo-bucket/test.txt

which will print the fourth field of the string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM