![]() You can probably do something like this: pattern=filenameįile_path="$(tar tzf 2>/dev/null| grep "$pattern")"Įcho "No files matching $pattern found in archive" You can't (easily) extract part of an archive to a different location from the one it's been archived under. You can't do this in one step, I'm afraid. This argument too is now wrapped in double quotes to protect it. ![]() We now use the switch -wildcards to the 2nd tar so that we can extract based on a pattern rather than just a single file. Also the argument to grep is also not wrapped in double quotes. ![]() Grep now includes the switch -E, because we're searching for a regular expression now and not just a single string within the output of tar. This is to protect the *Makefile from getting accidentally expanded. Notice that we've wrapped it in single quotes vs. ![]() We're extracting everything that matches '*Makefile'. The above involves a couple of additional changes. Tar ztvf $arc | grep -E "$file"
0 Comments
Leave a Reply. |