If you use s3cmd, you can use s3cmd get and write for stdout and direct it to head as follows:
s3cmd get s3://bucket/file | head
If you want to view gzip -d - gzip file, gzip -d - in gzip -d - and in gzip -d - :
s3cmd get s3://bucket/file | gzip -d - | head
If you get tired of this business, add the following script to your ~/.bashrc
function s3head() { NUM_LINES=10 while test $# -gt 0; do case $1 in -h|--help) echo "s3head [-n NUM] <S3_FILE_PATH>" return ;; -n) shift if test $# -gt 0; then export NUM_LINES=$1 else echo "Number of lines not specified" return fi shift ;; *) break ;; esac done if [[ -z "$1" ]]; then echo "S3 file path is not specified" return fi s3cmd get $1 - | zcat -f | head -n $NUM_LINES }
Now ~/.bashrc file ~/.bashrc . Just by running s3head s3://bucket/file , you will get the first 10 lines of your file. If you want more lines, just specify -n and the number of lines as follows:
Aswath k
source share