Linux命令在war文件中显示文件的内容

时间:2019-07-16 13:05:47

标签: linux command-line

我在Linux服务器上有一个war文件。
我需要在war文件中显示文件的内容。不仅显示战争文件中的内容。 我可以使用以下命令显示war文件的内容: jar -tvf file1.war

我需要在此war文件中显示清单文件的内容。 我以为可以使用管道添加if (elem.value.length > 140) { elem.style.color = 'red'; } else { elem.style.color = 'black'; } 命令,但是它的错误是:

  

没有这样的文件或目录

这是我尝试的命令: jar -tvf file1.war |猫META-INF / MANIFEST.MF

我使用什么命令查看war文件中清单文件的内容?

2 个答案:

答案 0 :(得分:1)

我发现了一些对我有用的东西...

  

解压缩-p file1.war META-INF / MANIFEST.MF

答案 1 :(得分:0)

您看到的是“没有这样的文件或目录”,因为cat命令找不到清单文件。这是因为jar的t选项仅列出war文件中的文件,而不提取它们。然后,将文件列表传递到cat META-INF/MANIFEST.MF中会导致错误消息,因为该文件不存在,因为它从未被提取。

请尝试使用x(用于提取)选项进行尝试:

# extract the MANIFEST.MF file
jar xvf file1.war META-INF/MANIFEST.MF
# cat it to the terminal
cat META-INF/MANIFEST.MF
# if you're sure that you're not deleting something important, then you can execute this to get rid of the META-INF directory:
# rm -rf META-INF
相关问题