lang-bash
#!/bin/bash
# check if the user put a file name
if [ $# -gt 0 ]; then
# check if the file is exist in the current directory
if [ -f "$1" ]; then
# check if the file is readable in the current directory
if [ -r "$1" ]; then
echo "File:$1"
echo "$(wc -c <"$1")"
# Note the following two lines
comp=$(bzip2 -k $1)
echo "$(wc -c <"$comp")"
else
echo "$1 is unreadable"
exit
fi
else
echo "$1 is not exist"
exit
fi
fi
Currently my problem is that I can compress the $1
file into a $1.c.bz2
file by bzip, but what if I come to capture the size of the compressed file. My code shows no such files.
Asked by alan
(1 rep)
Sep 17, 2021, 12:06 AM
Last activity: Sep 21, 2021, 07:11 AM
Last activity: Sep 21, 2021, 07:11 AM