11

I need to search for a file (logo.png), in a folder that contains war, ear, and jar archive files. Can anyone help me with the command?

3
  • 1
    Use this command in terminal ------> find [PATH] -name "[FILENAME]"
    – BDRSuite
    May 11, 2015 at 15:09
  • You mean finding files inside war, ear or jar archive file?
    – kenorb
    May 11, 2015 at 15:48
  • @kenorb yes exactly
    – ashok_p
    May 11, 2015 at 16:59

3 Answers 3

11

Searching inside jar files:

find . -name \*.jar -exec sh -c 'printf "\n\nFile: {}"; jar tf {}' ";" | less +/foo

And similar with war files:

find . -name \*.war -exec sh -c 'printf "\n\nFile: {}"; unzip -l {}' ";" | less +/foo

Change foo with text of your interest (such as abc.png).

You can press:

  • n to search for the next pattern match.
  • Shift+n to search backwards,
  • / + type something + Enter to search for another phrase.

See similar, but on Windows: Finding which jars contain a file

2
  • if i need to search abc.png file in a war archive how can i do with the above command.
    – ashok_p
    May 11, 2015 at 17:17
  • @ashok_p Replace Foo with abc.png.
    – kenorb
    May 11, 2015 at 18:47
2

You can use unzip command for this purpose:

unzip -t example.war |grep filename
0

jar tvf foo.war | grep filename

1
  • 1
    While this bit of code may be correct, the lack of ANY contextualizing information makes this answer useless and unhelpful. Jul 17, 2018 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .