Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 19
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 ...
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    98

    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

  2. #2
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,090
    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/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

  3. #3
    Linux Newbie egan's Avatar
    Join Date
    Feb 2009
    Location
    Mountain View, CA
    Posts
    132
    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.

  4. #4
    Linux Guru reed9's Avatar
    Join Date
    Feb 2009
    Location
    Boston, MA
    Posts
    4,651
    Let's not forget the excellent text based file manager, midnight commander.

  5. #5
    Just Joined!
    Join Date
    Apr 2009
    Posts
    98
    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?

  6. #6
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    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.

  7. #7
    Just Joined!
    Join Date
    Apr 2009
    Posts
    98
    And the same happened when i used the nano file_name command only it appears in a different type of language, code?

  8. #8
    Just Joined!
    Join Date
    Apr 2009
    Posts
    98
    Thought it would have appeared in every day readable English?

  9. #9
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,090
    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/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

  10. #10
    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

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...