Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Newbie > how to view a file in a terminal

Forgot Password?
 Linux Newbie   If you're new to the wonderful world of Linux, start here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 4 Weeks Ago   #1 (permalink)
Just Joined!
 
Join Date: Apr 2009
Posts: 60
how to view a file in a terminal

I have just started to learn how to use a terminal/command line and would like to know if it is possible to view a file whilst in a terminal. I am running Linux Mint 7.

I opened a terminal: branoo@computer ~ $

So i now added "ls" branoo@computer ~ $ ls
which listed all the directories.

I now wanted to access the Music directory so i used:
branoo@computer ~ $ cd Music

Which in turn produced a list of all the files within the Music directory

But could anyone tell me how i can view any of the files listed in the Music directory please
branoo is offline  


Reply With Quote
Old 4 Weeks Ago   #2 (permalink)
Super Moderator
 
ozar's Avatar
 
Join Date: May 2004
Posts: 12,058
You can view text files by opening them using the cat command, or you can open them with vi or nano:

Code:
cat file_name

nano file_name

You can find some quick command line lessons and tips here:

LinuxCommand.org: Learn the Linux command line. Write shell scripts.
__________________
oz

New Members: * README *
ozar is offline   Reply With Quote
Old 4 Weeks Ago   #3 (permalink)
Linux Newbie
 
egan's Avatar
 
Join Date: Feb 2009
Location: Mountain View, CA
Posts: 112
One of the nice (or tortuous) things about the command line is that you select the program to open a file. This is why standardized file extensions are important -- they serve to show the user what is in the file. If for some reason you don't know what kind of file something is, you can use the file command, e.g. file unknown.uk.

For text files you can use cat to dump the whole thing, more to dump it succesively, less to dump it with scrolling enabled, and a clean terminal afterwards. vi is better if you need syntax highlighting and if you want to edit it.

For images, I use qiv, which is nice and simple.

For movies and audio, I use mplayer, which integrates nicely with the commandline.

Hope some of this helps.
egan is offline   Reply With Quote
Old 4 Weeks Ago   #4 (permalink)
Linux Guru
 
reed9's Avatar
 
Join Date: Feb 2009
Location: Boston, MA
Posts: 2,202
Let's not forget the excellent text based file manager, midnight commander.
reed9 is offline   Reply With Quote
Old 4 Weeks Ago   #5 (permalink)
Just Joined!
 
Join Date: Apr 2009
Posts: 60
I navigated to a Directory in this case called Music typed the "ls" command just so i could see that the file i wanted to view was there, and finally i typed:

branoo@computer ~ $ Music cat file_name and clicked on enter and was rewarded with the following output?

:creator><dc:description><rdf:Seq><rdf:li>()</rdf:li></rdf:Seq></dc:description></rdfescription>
</rdf:RDF>
</xmpmeta>


<?xpacket end='w'?>
endstream
endobj
2 0 obj
<</Producer(GPL Ghostscript 8.64)
/CreationDate(D:20090419161637+01'00')
/ModDate(D:20090419161637+01'00')
/Title(\376\377\000C\000:\000\\\000D\000o\000c\000u \000m\000e\000n\000t\000s\000 \000a\000n\000d\000 \000S\000e\000t\000t\000i\000n\000g\000s\000\\\000 D\000e\000b\000b\000i\000e\000\\\000M\000y\000 \000D\000o\000c\000u\000m\000e\000n\000t\000s\000\ \\000S\000c\000o\000r\000e\000s\000\\\000T\000r\00 0a\000d\000\\\000D\000o\000w\000n\000B\000y\000S\0 00a\000l\000l\000y\000G\000a\000r\000d\000e\000n\0 00s\000.\000s\000i\000b)
/Creator(\376\377\000P\000D\000F\000C\000r\000e\000 a\000t\000o\000r\000 \000V\000e\000r\000s\000i\000o\000n\000 \0000\000.\0009\000.\000
/Author(\376\377\000D\000e\000b\000b\000i\000e)
/Keywords()
/Subject()>>endobj
xref
0 21
0000000000 65535 f
0000002919 00000 n
0000009563 00000 n
0000002860 00000 n
0000002718 00000 n
0000000015 00000 n
0000002698 00000 n
0000003865 00000 n
0000005276 00000 n
0000004185 00000 n
0000003272 00000 n
0000004251 00000 n
0000003529 00000 n
0000002984 00000 n
0000004450 00000 n
0000005476 00000 n
0000003045 00000 n
0000003441 00000 n
0000003597 00000 n
0000004049 00000 n
0000007418 00000 n
trailer
<< /Size 21 /Root 1 0 R /Info 2 0 R
/ID [<DF5B589BAE57424CF586FC7EDFA6C50E><DF5B589BAE57424 CF586FC7EDFA6C50E>]
>>
startxref
10319
%%EOF

I haven't a clue what is going on here?
branoo is offline   Reply With Quote
Old 4 Weeks Ago   #6 (permalink)
Linux Enthusiast
 
Join Date: Mar 2008
Posts: 602
Quote:
Originally Posted by branoo View Post
I haven't a clue what is going on here?
The content of the file got printed on standard output, which is your terminal.
This is what you wanted, no?
__________________
Debian GNU/Linux -- You know you want it.
GNU-Fan is offline   Reply With Quote
Old 4 Weeks Ago   #7 (permalink)
Just Joined!
 
Join Date: Apr 2009
Posts: 60
And the same happened when i used the nano file_name command only it appears in a different type of language, code?
branoo is offline   Reply With Quote
Old 4 Weeks Ago   #8 (permalink)
Just Joined!
 
Join Date: Apr 2009
Posts: 60
Thought it would have appeared in every day readable English?
branoo is offline   Reply With Quote
Old 4 Weeks Ago   #9 (permalink)
Super Moderator
 
ozar's Avatar
 
Join Date: May 2004
Posts: 12,058
As noted earlier, nano and vi will allow you to open and read text files.

Are you sure that the files that you are trying to open using nano are text files?
__________________
oz

New Members: * README *
ozar is offline   Reply With Quote
Old 4 Weeks Ago   #10 (permalink)
Just Joined!
 
Nickos's Avatar
 
Join Date: Oct 2009
Posts: 6
What do you mean by view a file in terminal ?

Code:
stat file.mp3
Nickos is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 04:27 PM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2