Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linux command to view a file

Posted on 2014-03-04
11
Medium Priority
?
494 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

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 1600 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

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.:
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.
Suggested Courses

609 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