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?

fixer1234
  • 27,064
  • 61
  • 75
  • 116
ashok_p
  • 213
  • 1
  • 2
  • 5

3 Answers3

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

kenorb
  • 24,736
  • 27
  • 129
  • 199
2

You can use unzip command for this purpose:

unzip -t example.war |grep filename
Romeo Ninov
  • 5,319
  • 5
  • 20
  • 20
0

jar tvf foo.war | grep filename

l33tHax0r
  • 111
  • 2
  • 1
    While this bit of code may be correct, the lack of ANY contextualizing information makes this answer useless and unhelpful. – music2myear Jul 17 '18 at 20:57