Solved

Linux command to view a file

Posted on 2014-03-04
11
478 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 22

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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

749 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