I want to write a script (or preferably an alias) that does the following:
- Find all the files matching a pattern
*.jar
- Iterate over all those files, and
run
jar tvf <jar file name> | grep <Some argument>
- Print if a
jar
contains a file with a name that matches theargument
I'm working on tcsh
and would prefer not to open a new shell since I want this as an alias and not a script - is it doable?
A straight alias isn't going to work for this application. Something like this would come close, except what you would get is the output of the grep, not the jar filename:
To get the filename, you should switch to using a function instead of an alias so that you have more control over arguments and where values go. (Note: bash format, you may need to modify for tcsh)
Try something along the lines of
read the man page for find for more details.