06-06-2013
Sorry about that, awk's getline always confuses me. It uses neither the C nor C++ convention for return value on these things, but some weird hybrid of both, causing the usual while(getline) most programmers expect to become an infinite loop as well.
Last edited by Corona688; 06-06-2013 at 05:37 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi all,
In a while loop, like below...
while read line
do
read choice
case $choice in
1)
echo "xxx"
esac
done < file
why I can't run the read choice???? (3 Replies)
Discussion started by: dta4316
3 Replies
2. Shell Programming and Scripting
Hi all
Does anyone have a script that will allow me to stop inside a while read loop.
I want to pause the loop until a enter is pressed.
e.g.
While read line
do
echo something
if LINECOUNT > 40
then
read ENTER?"PRESS ENTER TO CONT..."
... (3 Replies)
Discussion started by: jhansrod
3 Replies
3. Shell Programming and Scripting
Hi,
'read' command is not working inside the while loop, How can I solve this?
Rgds,
Sharif. (2 Replies)
Discussion started by: sharif
2 Replies
4. Shell Programming and Scripting
Im want to print filename inside loop .. the code im using :-
Filename_1=abc_20090623_2.csv.lk
Filename_2=def_20090623_2.csv.lk
i want to extract filename till .csv eg
Filename_1=abc_20090623_2
Filename_2=def_20090623_2
How can i do this inside the for loop
... (3 Replies)
Discussion started by: r_t_1601
3 Replies
5. Shell Programming and Scripting
Hi,
I have 100 files in a directory.
Each file have the following format
>CtbRe01234
fdfjdhfkdfkd
>CtL2B0456
gjfgfkgjfkgjfk
>CmdrE05768
fghdjskksllfkLike this I have many files in the directory.
What I want is; rename the header content in each file such that the above file... (6 Replies)
Discussion started by: Lucky Ali
6 Replies
6. Shell Programming and Scripting
AT
----------
0
Elapsed: 00:00:00.02
SO
----------
0
Elapsed: 00:00:00.01
SE
----------
0
Elapsed: 00:00:00.01
CR
---------- (4 Replies)
Discussion started by: sandy1028
4 Replies
7. Shell Programming and Scripting
Hi,
Need help in writing a script to read the contents of this file test
Test
00a
00b
00c
00d
00e
00f
where it need to read each line to give a display such as
form meta from dev 00a , config=Striped; add dev 00b:00f to meta 00a
Can any one help me in writing this script (2 Replies)
Discussion started by: praveen1516
2 Replies
8. Shell Programming and Scripting
Hi,
I am reading file records inside a while loop,
and want to update the record when certain condition is met.
How can I update a file while being read?
I want to avoid using temporary files, copy, rename, ...
while IFS=',' read -r f1 f2
do
function(f1,f2)
if
then
<add... (1 Reply)
Discussion started by: ysrini
1 Replies
9. Shell Programming and Scripting
I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix.
I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice.
Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies
10. Shell Programming and Scripting
Hi,
This query is a part of a much more lengthy script.
I wish to look for all the files in a folder named "data" which in this case has two files i.e. plan.war and agent.properties. For all the files found under data I wish to ask the user as to where they wish copy the files to.
Below,... (14 Replies)
Discussion started by: mohtashims
14 Replies
LEARN ABOUT CENTOS
getdelim
GETLINE(3) Linux Programmer's Manual GETLINE(3)
NAME
getline, getdelim - delimited string input
SYNOPSIS
#include <stdio.h>
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
getline(), getdelim():
Since glibc 2.10:
_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700
Before glibc 2.10:
_GNU_SOURCE
DESCRIPTION
getline() reads an entire line from stream, storing the address of the buffer containing the text into *lineptr. The buffer is null-termi-
nated and includes the newline character, if one was found.
If *lineptr is NULL, then getline() will allocate a buffer for storing the line, which should be freed by the user program. (In this case,
the value in *n is ignored.)
Alternatively, before calling getline(), *lineptr can contain a pointer to a malloc(3)-allocated buffer *n bytes in size. If the buffer is
not large enough to hold the line, getline() resizes it with realloc(3), updating *lineptr and *n as necessary.
In either case, on a successful call, *lineptr and *n will be updated to reflect the buffer address and allocated size respectively.
getdelim() works like getline(), except that a line delimiter other than newline can be specified as the delimiter argument. As with get-
line(), a delimiter character is not added if one was not present in the input before end of file was reached.
RETURN VALUE
On success, getline() and getdelim() return the number of characters read, including the delimiter character, but not including the termi-
nating null byte ('