Results 1 to 6 of 6

Thread: [RESOLVED] Quick terminal question

  1. #1

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Resolved [RESOLVED] Quick terminal question

    What's the command to output whatever is in a file.

    E.G. if there is a text file called hello.c. And if enter at the terminal:

    Code:
    kregg@vbf: ~ ???????? hello.c
    It would come up, as an example, the contents of the file

    c Code:
    1. #include <stdio.h>
    2.  
    3. int main
    4. {
    5.            printf("Hello goons");
    6.            return 0;
    7. }

    Thanks to anyone who can be bothered to tell me.

  2. #2

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: Quick terminal question

    It was cat.

  3. #3
    Hyperactive Member
    Join Date
    Oct 2006
    Posts
    354

    Re: [RESOLVED] Quick terminal question

    meow

  4. #4
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: [RESOLVED] Quick terminal question

    If you just want to print out the contents, cat is the best option. If you want to view a large text file one line at a time, then use the pager less.

    The cat command is not just used for printing out the contents of files. You can use it to pipe the file contents to another program, or even as a basic file splitting tool (in combination with the 'split' program).

    Code:
    $ split originalfile   # split the file into multiple parts
    
    $ cat part1 part2 part3 > originalfile   # join the parts back together
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  5. #5
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: [RESOLVED] Quick terminal question

    head or tail are also useful for dumping just the beginning or the end of the file.

    head and tail have command line args for specifying how many lines to show.

    see also tac and sort.
    I don't live here any more.

  6. #6

    Thread Starter
    Fanatic Member kregg's Avatar
    Join Date
    Feb 2006
    Location
    UK
    Posts
    524

    Re: [RESOLVED] Quick terminal question

    Thanks for that guys. I'll be busy on Wikipedia now

Posting Permissions

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



Click Here to Expand Forum to Full Width