[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

Linux command to view a file

I have a mywebapp.war  file  in ubuntu production server.
it has a web.xml file inside.

I want to  view this web.xml file.

What is the command to run ?   I dont want to unzip ....just want to view the content of web.xml file
0
cofactor
Asked:
cofactor
  • 4
  • 2
  • 2
  • +3
1 Solution
 
Patrick BogersDatacenter platform engineer LindowsCommented:
Hi

It is an archive which needs some kind of extraction like unzip before you can read the content.
0
 
ozoCommented:
unzip -p mywebapp.war  web.xml
0
 
cofactorAuthor Commented:
It is an archive which needs some kind of extraction like unzip before you can read the content.

I am trying to avoid it  because of big file size.
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
cofactorAuthor Commented:
unzip -p mywebapp.war  web.xml


two issues ...

1.   Dont  i require any editor to view files ?

2.  also  folder path is  mywebapp.war > WEB-INF > web.xml   .....what would be the correct command ?
0
 
Dave GouldCommented:
You can extract a single file from the .war as a .war is just a zipped archive.

unzip file.war web.xml

Yopu might need to add the full path to the xml file though
0
 
Dave GouldCommented:
Just refrreshed and saw that I missed your last post

unzip -p mywebapp.war WEB-INF/web.xml

And no you dont need an editor unless you are really stuck with vi or vim.
If you only want to look at the file, you can just use cat or more
0
 
MazdajaiCommented:
Use zipinfo to list the files in the war file then use unzip -p to pipe the contents on standard output.
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Your mywebapp.war is most likely unpacked on the webserver that runs your application, like Tomcat or JBoss for example. Do you know the location of your webserver? If you do, go there using cd and find your mywebapp.war - it should be unpacked and you could just view the web.xml using view or less.
0
 
cofactorAuthor Commented:
I'll give an update to this soon.
0
 
cofactorAuthor Commented:
what does  -p  does in unzip ?
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
From the manpage:

-p

extract files to pipe (stdout). Nothing but the file data is sent to stdout, and the files are always extracted in binary format, just as they are stored (no conversions).

So if  you use "unzip -p mywebapp.war web.xml" as ozo suggests, unzip would try and get web.xml from the .war file and display it on your console

But I just suggest you change to this:

unzip -p mywebapp.war WEB-INF/web.xml

Open in new window

as web.xml will be in the WEB-INF subfolder and the command suggested by ozo will give an error.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now