On Linux, we generally use the head/tail commands to preview the contents of a file. It helps in viewing a part of the file (to inspect the format for instance), rather than ope
If you don't want to download the whole file, you can download a portion of it with the --range option specified in the aws s3api
command and after the file portion is downloaded, then run a head
command on that file.
Example:
aws s3api get-object --bucket my_s3_bucket --key s3_folder/file.txt --range bytes=0-1000000 tmp_file.txt && head tmp_file.txt
Explanation:
The aws s3api get-object
downloads a portion of the s3 file from the specified bucket and s3 folder with the a specified size in --range to a specified output file.
The &&
executes the second command only if the first one has succeeded.
The second command prints the 10 first line of the previously created output file.