05-22-2008
Definitely C/C++ is faster than Shell Script.
Can you explain how fread is faster because i am going to read line by line only.
Regards
Kuttalaraj
7 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have written a script which does some editing in the files, based on user input.This might not be the most elegant way of doing it and there would be many improvements needed.
Please go through it and let me know how it could be improved.
Suggestions are welcome!!
Thanks!... (2 Replies)
Discussion started by: nua7
2 Replies
2. Shell Programming and Scripting
Hi!
Thank you for the help yesterday
This is the finished product
There is one more thing I would like to do to it but I’m not to certain
On how to proceed I would like to log all output to a log in order to
Be able to roll back
This script is meant to be used in repairing a... (4 Replies)
Discussion started by: Ex-Capsa
4 Replies
3. Infrastructure Monitoring
Hello,
I am pretty new to shell scripts and I recently wrote one that seems to do what it should but I am exploring the possibility of improving its performance and would appreciate some help. Here is what it does - Its meant to monitor a bunch of systems (reads in IPs one at a time from a flat... (9 Replies)
Discussion started by: prafulnama
9 Replies
4. UNIX for Advanced & Expert Users
can anyone help to share the knowledge on linux os improvement?
1) os account
- use window AD authentication, such as ldap, but how to set /etc/passwd, where to put user home?
2) user account activity
- how to log os user activity
share the idea and what tools can do that...thx (5 Replies)
Discussion started by: goodbid
5 Replies
5. Shell Programming and Scripting
Hi All,
Here is my script
#! /bin/sh
var1=some email id
var2=some email id
grep -i "FAILED FILE FORMAT VALIDATION" /opt >tmp2
diff tmp1 tmp2 | grep ">" >tmp3
if
then
cat tmp3 | mailx -s " Error Monitoring" $var2
else
echo "Pattern NOt Found" | mailx -s " Error Monitoring" $var1... (1 Reply)
Discussion started by: Gopalak
1 Replies
6. UNIX for Dummies Questions & Answers
Hi This is my Following code:
#!/bin/sh
echo "TOTAL_NO_OF_MAILS"
read TOTAL_NO_OF_MAILS
echo "TOTAL_NO_OF_TICKETS "
read TOTAL_NO_OF_TICKETS
echo "TICKETS_IN_QUEUE"
read TICKETS_IN_QUEUE
rm -rf `pwd`/Focus
echo "Hi Team\nSTATS IN CLRS MAIL BOX\n\n==============================" >> Focus... (11 Replies)
Discussion started by: wasim999
11 Replies
7. Shell Programming and Scripting
Below script is used to search numeric data from around 400 files in a folder. I have 300 such folders. Need help in performance improvement in the script.
Below Script searches 20 such folders ( 300 files in each folder) simultaneously. This increases cpu utilization upto 90% What changes... (3 Replies)
Discussion started by: vegasluxor
3 Replies
LEARN ABOUT OPENSOLARIS
fread
fread(3C) Standard C Library Functions fread(3C)
NAME
fread - binary input
SYNOPSIS
#include <stdio.h>
size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
DESCRIPTION
The fread() function reads into the array pointed to by ptr up to nitems elements whose size is specified by size in bytes, from the stream
pointed to by stream. For each object, size calls are made to the fgetc(3C) function and the results stored, in the order read, in an array
of unsigned char exactly overlaying the object. The file-position indicator for the stream (if defined) is advanced by the number of bytes
successfully read. If an error occurs, the resulting value of the file-position indicator for the stream is unspecified. If a partial ele-
ment is read, its value is unspecified.
The fread() function may mark the st_atime field of the file associated with stream for update. The st_atime field will be marked for
update by the first successful execution of fgetc(3C), fgets(3C), fgetwc(3C), fgetws(3C), fread(), fscanf(3C), getc(3C), getchar(3C),
gets(3C), or scanf(3C) using stream that returns data not supplied by a prior call to ungetc(3C) or ungetwc(3C).
RETURN VALUES
Upon successful completion, fread() returns the number of elements successfully read, which is less than nitems only if a read error or
end-of-file is encountered. If size or nitems is 0, fread() returns 0 and the contents of the array and the state of the stream remain
unchanged. Otherwise, if a read error occurs, the error indicator for the stream is set and errno is set to indicate the error.
ERRORS
Refer to fgetc(3C).
EXAMPLES
Example 1 Reading from a Stream
The following example reads a single element from the fp stream into the array pointed to by buf.
#include <stdio.h>
...
size_t bytes_read;
char buf[100];
FILE *fp;
...
bytes_read = fread(buf, sizeof(buf), 1, fp);
...
USAGE
The ferror() or feof() functions must be used to distinguish between an error condition and end-of-file condition. See ferror(3C).
Because of possible differences in element length and byte ordering, files written using fwrite(3C) are application-dependent, and possibly
cannot be read using fread() by a different application or by the same application on a different processor.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
read(2), fclose(3C), ferror(3C), fopen(3C), getc(3C), gets(3C), printf(3C), putc(3C), puts(3C), attributes(5), standards(5)
SunOS 5.11 24 Jul 2002 fread(3C)