Hi all I'm attempting to create a script that searches through archive files (.zip, .tzr, .tzr.gz) to find a particular file for me. I found this online:
Code:
grab () {
find /directory_path -iname "*.tar.gz" -exec tar tz -f '{}' \; | grep $1
find /directory_path -iname "*.tar" -exec tar t '{}' \; | grep $1
find /directory_path -iname "*.zip" -exec unzip -l '{}' \; | grep $1
}
grab *foo*.bar
I have been attempting to use it like this:
./script *foo*.bar
But it doesn't want to work and I have no idea why. It doesn't ouput an error or access the HDD, so I don't think it's actually doing anything. Basically I'm looking for anything of filetype ".bar" with "foo" as part of the filename (e.g. *foo*.bar). Also I would assume I put "*foo*.bar" in as argument 1 ($1) but I would like some clarification on it.
I also need it to search through the uncompressed directories and subdirectories as well, so I would probably just add a standard "find" or "grep" funtion to the start of it as well. Any advice?