Hi,
I want to change a particular string in a file with another string. This is part of a larger script file. I m using SED for this purpose:
sed -e 's/hostname.domainname/${HOST}.${DOMAIN}/g' $sed_file>$tmp_file
Where the occurance hostname.domainname has to be replaced with the... (4 Replies)
Okay, title is kind of confusion, but basically, I have a lot of scripts on a server that I need to replace a ps command, however, the new ps command I'm trying to replace the current one with pipes to sed at one point. So now I am attempting to create another script that replaces that line.
... (1 Reply)
my script:
amount1=`tail /tmp/file1.txt`
amount2=`tail /tmp/file2.txt`
sed -e 's/'${amount2}'/'${amount1}'/g' filename1 > filename2
what did i do wrong ? i just want to replace amount1 with amount2 value. (2 Replies)
Hi,
i am following content in file
cat file
Install Installation-path variable
Now i need to replace Installation-path with some text to be provided as argument in csh script invocation
My question is , can i replace this by only using path
eg.
sed "s/path/$1" file
but it... (1 Reply)
I'm trying to change a "." in a file name with a "_"
I have tried;
sed -e 's/./_/g'
However this then replaces the entire filename with a load of "_"
For example;
ls /usr/local/feed/service/customers/test1/configs/test1.httpsend | awk -F/ '{print $9}' | tr "" "" | sed -e "s/./_/g"
... (2 Replies)
Hello,
I have a comman separated file lets day data.txt in following format
,:000002 CH XIN9I.INDX, 34.7534909645,:000002 CH,:Index XIN9I.INDX
,:000063 CH XIN9I.INDX, 6.3062924781,:000063 CH,:Index XIN9I.INDX
,:000776 CH XIN9I.INDX, 2.7001954832,:000776 CH,:Index XIN9I.INDX
I would like... (9 Replies)
Hi,
I have values in a file at Place $1 as AmericanDollar, AustralianDollar, Singapore1Dollar and so on on various rows. I want to replace Dollar with Pound for all those records where no numeric character is present in the string. Means in above mentioned values 'Singapore1Dollar' should not be... (11 Replies)
Hi,
i have a file as give below
>cat sample_file
param1 val1 2012-06-19
##there can be one or more space after 2012-06-19 in the above file
i want to replace val1 with a with value passed through a variable...
below is the command i tried
>parval='param1 val2'
>par1=param1
>sed... (3 Replies)
How can we empty or replace with null, following block of code (within the php quotes including the quotes) from inside a file.
*** some other data above this code
<?
#317008#
... (5 Replies)
Discussion started by: fed.linuxgossip
5 Replies
LEARN ABOUT NETBSD
getline
GETDELIM(3) BSD Library Functions Manual GETDELIM(3)NAME
getdelim, getline -- read a delimited record from a stream
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdio.h>
ssize_t
getdelim(char ** restrict lineptr, size_t * restrict n, int delimiter, FILE * restrict stream);
ssize_t
getline(char ** restrict lineptr, size_t * restrict n, FILE * restrict stream);
DESCRIPTION
The getdelim() function reads from the stream until it encounters a character matching delimiter, storing the input in *lineptr. The buffer
is NUL-terminated and includes the delimiter. The delimiter character must be representable as an unsigned char.
If *n is non-zero, then *lineptr must be pre-allocated to at least *n bytes. The buffer should be allocated dynamically; it must be possible
to free(3) *lineptr. getdelim() ensures that *lineptr is large enough to hold the input, updating *n to reflect the new size.
The getline() function is equivalent to getdelim() with delimiter set to the newline character.
RETURN VALUES
The getdelim() and getline() functions return the number of characters read, including the delimiter. If no characters were read and the
stream is at end-of-file, the functions return -1. If an error occurs, the functions return -1 and the global variable errno is set to indi-
cate the error.
The functions do not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred.
EXAMPLES
The following code fragment reads lines from a file and writes them to standard output.
char *line = NULL;
size_t linesize = 0;
ssize_t linelen;
while ((linelen = getline(&line, &linesize, fp)) != -1)
fwrite(line, linelen, 1, stdout);
if (ferror(fp))
perror("getline");
ERRORS
[EINVAL] lineptr or n is a NULL pointer.
[EOVERFLOW] More than SSIZE_MAX characters were read without encountering the delimiter.
The getdelim() and getline() functions may also fail and set errno for any of the errors specified in the routines fflush(3), malloc(3),
read(2), stat(2), or realloc(3).
SEE ALSO ferror(3), fgets(3), fopen(3)STANDARDS
The getdelim() and getline() functions conform to IEEE Std 1003.1-2008 (``POSIX.1'').
BSD June 30, 2010 BSD