Hi everyone
I'm trying to read several compressed files and compare the extension inside files.
Example:
Code:
namezip[0]=.tar.bz2
namezip[1]=.tar.gz
namezip[2]=.bz2
namezip[3]=.rar
namezip[4]=.gz
namezip[5]=.tar
namezip[6]=.tbz2
namezip[7]=.tgz
namezip[8]=.zip
namezip[9]=.Z
namezip[10]=.7z
for i in ${namezip[@]}
do
zcat $i | head
done
Want to to read the extension.
Example; .iso , .exe , .sh , .html , .txt , .mp3 , ...
If it's a text file ( with zcat there is no symbol ( only text )
Extract all text file
If .iso .exe .mp3 ( with zcat there is WEIRD symbol )
fkw|������T��T�9�9Y&34Y>Y\
do not extract
Is there a way to find them?
If we can't, can i compare first letter ( cut -c1 ) with something else..
Example:
Code:
letter=`echo {a..z}`
firstletter=`zcat $i | head | cut -c1`
if [ "$firstletter" = "${letter[@]}" ]
then
...
fi
Thanks for your help