• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 501
  • 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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 GouldOnsite SupportCommented:
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 GouldOnsite SupportCommented:
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

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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