-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_tarball_index.sh
executable file
·44 lines (38 loc) · 1.21 KB
/
make_tarball_index.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#! /bin/bash
#
############################################################################
#
# MODULE: make_tarball_index.sh
#
# AUTHOR: Eric Patton, Geological Survey of Canada (Atlantic)
# <Eric dot Patton at Canada dot ca>
#
# PURPOSE: This script reads through a tarball using the -t flag and
# creates an index of the files contained within for easy reference.
#
# COPYRIGHT: (c) 2022 by Eric Patton
#
# This program is free software under the GNU General Public
# License (>=v3).
#
# Created: January 30, 2022
# Last Modified: January 30, 2022
#
#############################################################################
SCRIPT=$(basename $0)
if [ "$#" -ne 1 -o "$1" == "-H" -o "$1" == "-h" -o "$1" == "--help" -o "$1" == "-help" ] ; then
echo -e "\nusage: $SCRIPT tarfilename"
echo "Creates an index listing of the given tarball in the current directory."
exit 1
fi
# What to do in case of user break:
exitprocedure()
{
echo -e "\n\n$SCRIPT: User break or similar caught; Exiting.\n"
exit 1
}
# Setup clean exit for Ctrl-C or similar breaks.
trap 'exitprocedure' 2 3 15
INPUT=$1
tar -tnvf ${INPUT} | awk '{print $6}' | tee ${INPUT}.idx
exit 0