i know how to find file with find
# find /root/directory/to/search -name 'filename.*'
but, how to look also into archives, as file can be ziped inside...
thanx
I defined a function (zsh, minor changes -> BaSh)
## preview archives before extraction
# Usage: show-archive <archive>
# Description: view archive without unpack
show-archive() {
if [[ -f $1 ]]
then
case $1 in
*.tar.gz) gunzip -c $1 | tar -tf - -- ;;
*.tar) tar -tf $1 ;;
*.tgz) tar -ztf $1 ;;
*.zip) unzip -l $1 ;;
*.bz2) bzless $1 ;;
*) echo "'$1' Error. Please go away" ;;
esac
else
echo "'$1' is not a valid archive"
fi
}
You can
find /directory -name '*.tgz' -exec show-archive {} \| grep filename \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With