Last active
August 29, 2015 14:14
-
-
Save cjjavellana/1c109ffa015169fde8a1 to your computer and use it in GitHub Desktop.
Tar, Compress and Split Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$1" != "" ] | |
then | |
log_dir="temp_$1" | |
echo "Archiving *.war to dailylog_$1.tar" | |
tar cvf dailylog_$1.tar *.war | |
echo "Compressing dailylog_$1.tar" | |
gzip dailylog_$1.tar | |
file_size=`ls -l dailylog_$1.tar.gz | awk '{print $5}'` | |
echo "Creating directory $log_dir" | |
mkdir -p $log_dir | |
if [ "$file_size" -gt "30000" ] | |
then | |
echo "Splitting files ... " | |
split -b 30k -d dailylog_$1.tar.gz dailylog_$1.tar.gz_ | |
echo "Moving split files to $log_dir" | |
mv dailylog_$1.tar.gz_* $log_dir | |
fi | |
echo "Moving Main File to $log_dir" | |
mv dailylog_$1.tar.gz $log_dir | |
echo "Listing contents of $log_dir" | |
ls -ltr $log_dir | |
else | |
echo "Usage:" | |
echo "tarsplit.sh [timestamp]" | |
echo "" | |
echo "Example:" | |
echo "tarsplit.sh 050220152100" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment