Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. export AWS_PROFILE=default
  4.  
  5. FULLPATH="s3://jayers99-flowlog-test/AWSLogs/441655563487/vpcflowlogs/"
  6. BUCKET=$(echo "$FULLPATH" | cut -d "/" -f3)
  7. echo "#$BUCKET#";
  8. echo ;
  9.  
  10. LASTFILES=$(aws s3 ls $FULLPATH --recursive | sort | tail -n 10 | awk '{print $4}')
  11.  
  12. rm ./lastfile
  13.  
  14. for i in $LASTFILES; do
  15. if [ ! -f ./lastfile$i ]; then
  16. aws s3 cp s3://$BUCKET/$i ./lastfile$i
  17. fi
  18. gunzip -c ./lastfile$i >> ./lastfile
  19. done
  20.  
  21. cat ./lastfile | ggrep -P '^((?!version|NODATA).)*$' | awk '{ cmd="date -r "$11" +%Y-%m-%dT%H:%M:%S"; cmd | getline myTime; close(cmd); printf "%s %-15s %-15s\n", myTime, $4, $5 }' | sort
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement