Skip to content

Instantly share code, notes, and snippets.

@normcyr
Last active April 25, 2018 19:27
Show Gist options
  • Save normcyr/a1edad3c5a2fd313b6217f0ac4c1233f to your computer and use it in GitHub Desktop.
Save normcyr/a1edad3c5a2fd313b6217f0ac4c1233f to your computer and use it in GitHub Desktop.
Create a GZIP compressed file containing SAXS data of a user
#!/bin/bash
# ------------------------------------------------------------------
# [Normand Cyr] tar_data.sh
# Create a GZIP compressed file containing SAXS data of a user
# ------------------------------------------------------------------
VERSION=0.1.0
#USAGE="Usage: tar_data -ihv args"
# name of the data file to create
data_file_name="saxs_data.tar"
data_file_name_gzip=$data_file_name".gz"
# output message
echo
echo "Creating a compressed file containing SAXS data numbered $1 to $2."
echo
# parse CLI start and end arguments
for i in $(seq $1 $2)
do
# add each corresponding file to tar
for file in "0"$i"*.tiff"
do
tar rf $data_file_name $file
done
done
# gzip the tar archive and remove the tar
tar cfz $data_file_name_gzip $data_file_name
rm $data_file_name
echo "Done."
echo "The full name of the compressed archive is"
echo
echo $(pwd)"/$data_file_name_gzip"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment