It's old bag/feature. "While read" doesn't work when the last line of a file doesn't end with newline char. It reads the line but returns false (non-zero) value.
Hello All,
Request you to let me know how to do the below urgently..
Requirement
File A Contains:
for i in file A
DEV1
DEV5
STG1
STG5
File B Contains:
for j in file B
DEV1
DEV5
STG1
STG5 (3 Replies)
hi all,
i have a while loop which i am using to read lines into an array:
k=0
exec 10<file
while read LINE <&10; do
ARRAY=$LINE
((k++))
done
exec 10>&-
echo ${ARRAY}
for some reason when i display the array it is not showing the last row in the file.
any help appreciated. (1 Reply)
I am using the while-loop to read a file.
The file has lines with null-terminated strings (words, actually.)
What I have by that reading - just a first word up to '\0'!
I need to have whole string up to 'new line' - (LF, 10#10, 16#A)
What I am doing wrong?
#make file 'grb' with... (6 Replies)
I know I should be able to see a way of doing this easily, but my brain just won't engage.
I have a script working on an embedded device that checks to see if an item is in a blacklist before performing some actions.
At the moment the code reads thus....
while read BLACKLIST ; do
... (7 Replies)
Hello All,
i am a newbie and need some help when reading a csv file in a bourne shell script. I want to read 10 lines, then wait for a minute and then do a reading of another 10 lines and so on in the same way. I want to do this till the end of file.
Any inputs are appreciated
... (3 Replies)
Hi Guys
I am new to scripting.Please forgive for asking basic questions.
I want to write a script to check whether the logs are getting updated in last 15 mins.
cat server
192.168.1.6
192.168.1.7
cat list
192.168.1.7 /logs/logpath1
192.168.1.7 /logs/logpath2
192.168.1.6... (4 Replies)
Hello Team,
i have to read line by line in a while loop, and the input file has:.
# The script will start cppunit test application to run unit tests.
-LD_LIBRARY_PATH=$CPPUNIT_HOME/lib:\
+LD_LIBRARY_PATH=$VOBTAG/SS_UnitTest/lib:\
$VOBTAG/SS_BFD/BFDSCLI/build:\
... (7 Replies)
Hi,
I want to read a live log file line by line and considering those line which start from time stamp;
Below code I am using, which read line but throws an exception when comparing line that does not contain error code
tail -F /logs/COMMON-ERROR.log | while read myline; do... (2 Replies)
Hello,
I am using below code for reading from a file and assigning the values to a variable , but it is loosing the value after the loop , please suggest to retain the value of the variable after the loop ,
while IFS=: read -r line
do
set $dsc=$line
echo 'printing line variable ' $line... (1 Reply)
Hello,
I'm using RHEL 5.1 with bash. How to handle "read" inside while loop reading every line? Please see below:
# cat /tmp/passwd_sample
CARRJ12:qVSn4ja4mFA72,..:20021:125:JULIAN CARR:/home/everyone:/bin/bash
HERCOT01:NK/3j2ZB4ZC7Q:20022:125:TOM HERCOCK:/home/everyone:/bin/bash... (4 Replies)
Discussion started by: reddyr
4 Replies
LEARN ABOUT DEBIAN
xfopen
FILES(3pub) C Programmer's Manual FILES(3pub)NAME
xgetaline, xfseek, xfopen, xfclose, getaline, fassert - file manipulation utilities
SYNOPSIS
#include <files.h>
FILE *xfopen(const char *filename, const char *mode);
void xfclose(FILE *fp);
void xfseek(FILE *fp, long offset, int origin);
char *getaline(FILE *fp);
char *xgetaline(FILE *fp);
void fassert(FILE *fp);
DESCRIPTION
These functions are useful for file manipulation. The functions that begin with x work like the functions without the letter, except if
there is an error, they print an error message and kill the program.
getaline reads a line from the given file. It allocates the memory for the line with malloc(3), and returns a pointer to the beginning of
the line. If there is an error, it returns NULL. If the returned value is not NULL, the caller is responsible for freeing the memory.
The newline is removed from the end of the line.
fassert checks that the argument is not NULL, and that (for a non-NULL argument) the file does not have its error indicator flag set. If
either condition is true, it prints an error message and termiantes the program. If neither condition is true, it does nothing. This can
be used to add checks that the I/O in a program is going well; however, it is mostly useful only for small programs, because more serious
programs need to handle the errors more gracefully.
SEE ALSO publib(3)AUTHOR
Lars Wirzenius (lars.wirzenius@helsinki.fi)
Publib C Programmer's Manual FILES(3pub)