If you display several line of text from you input file, maybe we can do better than just guess as to what we we're reading. I do not see why you have getline in there. Your expected output is just a single line, per your example.
Hi,
I need to match lines after a pattern, upto the first blank line.
Searched in web and some forums but coulnt find the answer.
where <restart_step> =
10 -- Execute query
20 -- Write the contents to the Oracle table
30 -- Writing Contents to OUTPUT... (7 Replies)
i have a file which contains alphanumeric data in every line. what i need is the data after certain pattern. the data after the pattern is not of fixed length so i need the data till the space after the pattern.
Input file:
bfdkasfbdfg khffkf lkdhfhdf pattern (datarequired data not required)... (2 Replies)
Hi,
I have got the below requirement. please suggest.
I have a file like,
Processing Item is:
/data/ing/cfg2/abc.txt
/data/ing/cfg3/bgc.txt
Processing Item is:
/data/cmd/for2/ght.txt
/data/kernal/config.klgt.txt
I want to process the above file to get the output file like,
... (5 Replies)
I have a file which is like this
………………………………………..
…………………………………
…………………………………
……………………………………
…………………………………….
………………………………
<<<from_here>>>
………………………………
……………………………….
I want a script which would fetch the data starting from <<<from_here>>> in the file till the end... (2 Replies)
hi guys,
im trying to add the following line in my xml file
<dbrollbacksegs <oa_var="s_db_rollback_segs">NOROLLBACK</dbrollbacksegs>
when ever i find the following line
<dbsharedpool oa_var="s_dbsharedpool_size">300000000</dbsharedpool>
I have succedded till adding a new line... (1 Reply)
I had a spot of trouble coming up with a title, hopefully you'll understand once you read my problem... :)
I have the output of an ldapsearch that looks like this:
dn: cn=sam,ou=company,o=com
uidNumber: 7174
gidNumber: 49563
homeDirectory: /home/sam
loginshell: /bin/bash
uid: sam... (2 Replies)
" Script for display sentences with special character"
Hi,
Could any one share a command how to display a line until my target word.
For ex: My file has the content as:
select * from db_wrk where col1 < col2
insert into table_name values('1','2','tst','wrk','dev','prod')
My target... (10 Replies)
hi,
i have /etc/inittab, I want to add another line after that when i find a pattern "l6:6:wait:/etc/rc.d/rc 6".
original
l6:6:wait:/etc/rc.d/rc 6
after-change
l6:6:wait:/etc/rc.d/rc 6
/sbin/if-pp-to-cng (3 Replies)
Im using the command below , but thats not the output that i want. it only prints the odd and even numbers.
awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}'
Im hoping for something like this
file1:
Text hi this is just a test
text1 text2 text3 text4 text5 text6
Text hi... (2 Replies)
Looking for help,
i have input file like below and want to modify to expected output, if can without create additional file, hope can direct modify it.
have 2 thing need do.
1st
is adding a word (testplan generation off) after ! ! IPG: Tue Aug 07 14:31:17 2018
2nd
is adding... (16 Replies)
Discussion started by: kttan
16 Replies
LEARN ABOUT DEBIAN
getline
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. This value can be used to handle embedded null bytes in the line read.
Both functions return -1 on failure to read a line (including end-of-file condition).
ERRORS
EINVAL Bad arguments (n or lineptr is NULL, or stream is not valid).
VERSIONS
These functions are available since libc 4.6.27.
CONFORMING TO
Both getline() and getdelim() were originally GNU extensions. They were standardized in POSIX.1-2008.
EXAMPLE
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
int
main(void)
{
FILE *fp;
char *line = NULL;
size_t len = 0;
ssize_t read;
fp = fopen("/etc/motd", "r");
if (fp == NULL)
exit(EXIT_FAILURE);
while ((read = getline(&line, &len, fp)) != -1) {
printf("Retrieved line of length %zu :
", read);
printf("%s", line);
}
free(line);
exit(EXIT_SUCCESS);
}
SEE ALSO read(2), fgets(3), fopen(3), fread(3), gets(3), scanf(3)COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2010-06-12 GETLINE(3)