04-24-2008
Tested here; looks like I'm right. If I hit ctrl-c after five seconds (enough to produce about two matching lines, I guess) the output file is empty. If I run it for a minute or so, I still don't get output in the file. Then all of a sudden, lots of output. It's output buffering at play.
If you have grep --line-buffered, try with that, just to see that it works. If you run it for long enough, you probably want to take it out again, though.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Is there a way to collect data from top command to a file at regular intervals. I need this on HP-UX. I need to gather resident memory usage. I know that sar will give %cpu usage. There is a pmap command which gives memory usage in solaris. Is there a similar command in HP-UX
Thanks (5 Replies)
Discussion started by: sssow
5 Replies
2. UNIX for Dummies Questions & Answers
What command do I use in order to save a file in directory A/B/C
to directory A/D/E. (1 Reply)
Discussion started by: JSP
1 Replies
3. Shell Programming and Scripting
Is this possible? I am attempting to display a new xterm window and tail -f the log file within that new window. I am currently working on a solaris 8 machine if that has any different meaning than the other platforms. As you can see, I am a newbie to this forum and to UNIX. Any help would be... (2 Replies)
Discussion started by: douknownam
2 Replies
4. AIX
hi all,
i do search for a file in solaris box in the following format
find / -name 'file' -print 2>/dev/null
i tried the same thing on AIX box;
as i am searching from the root the same way i redirected the errors to /dev/null but find is showing strip off errors and when i just continued... (1 Reply)
Discussion started by: matrixmadhan
1 Replies
5. UNIX for Dummies Questions & Answers
hi,
Is there a way to access the redirected file inside the script. Here is what the command line looks like:
$ shar * > archive_file.arc
I know I can't access the name of archive_file.arc with positional parameters like $1, $2.. Is there any way to figure out what file the output of the... (3 Replies)
Discussion started by: milhan
3 Replies
6. UNIX for Dummies Questions & Answers
I have to confirm that an engine was not able to run. In the output below you see that it indeed got errors, but it didn't send those messages to the output file. When I run the same thing with a different executable it works. So does this mean something in the executable could cause it not to... (7 Replies)
Discussion started by: brdholman
7 Replies
7. Programming
Hello everybody,
Having a file with the following content:
192.168.0.254->192.168.0.1
192.168.0.2->192.168.0.34
192.168.0.56->192.168.0.77
I need to code a program in C to read it from stdin redirection (i.e. root@box~# ./a.out < file), my question is, how can i do that?
I've tried with... (2 Replies)
Discussion started by: semash!
2 Replies
8. Shell Programming and Scripting
Hi,
I have one file, say file 1, that has data like below where 19900107 is the date,
19900107 12 144 129 0.7380047
19900108 12 168 129 0.3149017
19900109 12 192 129 3.2766666E-02
... (3 Replies)
Discussion started by: Wynner
3 Replies
9. UNIX and Linux Applications
Hi,
Pls check that '|' and '+' present in Step-1 are not copied to log file in Step-3.
Pls suggest how to get the exact output from Step-1 (i.e. with out losing '|' and '+') in to a log file
~Thanks
Step-1: Execute command
> mysql -utest -ptest -htesthost testdb -e "select * from... (3 Replies)
Discussion started by: newbielgn
3 Replies
10. Shell Programming and Scripting
Hi
echo " username "
read username
echo "password"
stty -echo
read password
stty echo
through read i am taking standard input and redirecign them to a file
echo " username=${username}/${password} " > file.lst
now from the same shell script i want to delete the password (i.e... (4 Replies)
Discussion started by: rosheks
4 Replies
LEARN ABOUT ULTRIX
setbuffer
setbuf(3s) setbuf(3s)
Name
setbuf, setbuffer, setlinebuf, setvbuf - assign buffering to a stream
Syntax
#include <stdio.h>
void setbuf(stream, buf)
FILE *stream;
char *buf;
void setbuffer(stream, buf, size)
FILE *stream;
char *buf;
int size;
void setlinebuf(stream)
FILE *stream;
int setvbuf(stream, buf, type, size)
FILE *stream;
char *buf;
int type; size_t size;
Description
The three types of buffering available are unbuffered, block buffered, and line buffered. When an output stream is unbuffered, information
appears on the destination file or terminal as soon as written; when it is block buffered many characters are saved up and written as a
block; when it is line buffered characters are saved up until a new line is encountered or input is read from stdin. The routine may be
used to force the block out early. Normally all files are block buffered. For further information, see A buffer is obtained from upon the
first or on the file. If the standard stream stdout refers to a terminal it is line buffered. The standard stream stderr is always
unbuffered.
The routine is used after a stream has been opened but before it is read or written. The character array buf is used instead of an auto-
matically allocated buffer. If buf is the constant pointer NULL, input/output will be completely unbuffered. A manifest constant BUFSIZ
tells how big an array is needed:
char buf[BUFSIZ];
The routine, an alternate form of is used after a stream has been opened but before it is read or written. The character array buf whose
size is determined by the size argument is used instead of an automatically allocated buffer. If buf is the constant pointer NULL,
input/output will be completely unbuffered.
The routine is used to change stdout or stderr from block buffered or unbuffered to line buffered. Unlike and it can be used at any time
that the file descriptor is active.
The routine may be used after a stream has been opened but before it is read or written. Type determines how stream will be buffered.
Legal values for type, defined in stdio.h are:
_IOFBF causes input/output to be fully buffered.
_IOLBF causes output to be line buffered; the buffer will be flushed when a new line is written, the buffer is full, or input is
requested.
_IONBF causes input/output to be completely unbuffered.
If buf is not the NULL pointer, the array it points to will be used for buffering, instead of an automatically allocated buffer. The size
specifies the size of the buffer to be used. The constant BUFSIZ in <stdio.h> is suggested as a good buffer size. If input/output is
unbuffered, buf and size are ignored.
By default, output to a terminal is line buffered and all other input/output is fully buffered.
A file can be changed from unbuffered or line buffered to block buffered by using For further information, see A file can be changed from
block buffered or line buffered to unbuffered by using followed by with a buffer argument of NULL.
Restrictions
The standard error stream should be line buffered by default.
The and functions are not portable to non 4.2 BSD versions of UNIX.
See Also
malloc(3), fclose(3s), fopen(3s), fread(3s), getc(3s), printf(3s), putc(3s), puts(3s).
setbuf(3s)