|
-
Jul 29th, 2007, 01:33 PM
#1
Thread Starter
Fanatic Member
[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:
#include <stdio.h>
int main
{
printf("Hello goons");
return 0;
}
Thanks to anyone who can be bothered to tell me.
-
Jul 29th, 2007, 02:14 PM
#2
Thread Starter
Fanatic Member
Re: Quick terminal question
-
Jul 29th, 2007, 10:28 PM
#3
Hyperactive Member
Re: [RESOLVED] Quick terminal question
-
Jul 30th, 2007, 03:35 AM
#4
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
-
Jul 30th, 2007, 06:20 AM
#5
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.
-
Sep 7th, 2007, 10:38 AM
#6
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|