Solved

Linux command to view a file

Posted on 2014-03-04
11
482 Views
Last Modified: 2014-05-14
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
Comment
Question by:cofactor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +3
11 Comments
 
LVL 23

Expert Comment

by:Patrick Bogers
ID: 39905602
Hi

It is an archive which needs some kind of extraction like unzip before you can read the content.
0
 
LVL 84

Expert Comment

by:ozo
ID: 39905617
unzip -p mywebapp.war  web.xml
0
 

Author Comment

by:cofactor
ID: 39905623
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
Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

 

Author Comment

by:cofactor
ID: 39905687
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
 
LVL 5

Expert Comment

by:Dave Gould
ID: 39905736
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
 
LVL 5

Accepted Solution

by:
Dave Gould earned 400 total points
ID: 39905739
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
 
LVL 21

Expert Comment

by:Mazdajai
ID: 39906727
Use zipinfo to list the files in the war file then use unzip -p to pipe the contents on standard output.
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 39908077
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
 

Author Comment

by:cofactor
ID: 39943521
I'll give an update to this soon.
0
 

Author Comment

by:cofactor
ID: 40012241
what does  -p  does in unzip ?
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 40012262
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

689 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question