-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtgz2zip
More file actions
executable file
·34 lines (25 loc) · 747 Bytes
/
tgz2zip
File metadata and controls
executable file
·34 lines (25 loc) · 747 Bytes
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
#!/bin/bash
#
export PATH=$PATH:`pwd`
echo PATH $PATH
# Check if a filename was provided
if [ $# -eq 0 ]; then
echo "Please provide a .tgz file name"
exit 1
fi
# Get the input filename and output filename
input_file="$1"
output_file="${input_file%.tgz}.zip"
# Create a temporary directory
temp_dir=$(mktemp -d)
# Extract .tgz contents to the temporary directory
tar -xzf "$input_file" -C "$temp_dir"
# Change to the temporary directory
echo $temp_dor
( cd "$temp_dir" && zip -r "$output_file" ./* )
# Create zip file
# Move the zip file to the original directory
mv "$temp_dir/$output_file" "$(dirname "$input_file")"
# Clean up: remove temporary directory
rm -rf "$temp_dir"
echo "Conversion complete. Output file: $output_file"