Can someone tell me how I can do this?
e.g:
a=$(echo -e wert trewt ertert ertert ertert erttert
erterte
rterter
tertertert
ert)
How do i replace the STRING with $a?
I try this:
sed -i 's/STRING/'"$a"'/g' filename.ext
but this don' t work (2 Replies)
continuing from my previous post, whose link is given below as a reference
https://www.unix.com/shell-programming-scripting/171076-shell-scripting.html#post302573569
consider there is create table commands in a file for eg:
CREATE TABLE `Blahblahblah` (
`id` int(11) NOT NULL... (2 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Hi,
I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
I have 2 files generated in linux that has common output and were produced across multiple hosts with the same setup/configs. These files do some simple reporting on resource allocation and user sessions. So, essentially, say, 10 hosts, with the same (2) system reporting in the files, so a... (0 Replies)
I need to read a text file and insert a string every n lines, but also have the line counter restart when I come across a header string.
Line repeating working every 3 lines using code:
sed '0~3 s/$/\nINSERT/g' < INPUT/PATH/FILE_NAME.txt > OUTPUT/PATH/FILE_NAME.txt
I cannot seem to find... (1 Reply)
I have the logic below to look up for matches within the columns between the two files with awk.
In the if statement is where the string comparison is attempted with ==
The issue seems to be with the operands, as
1. when " '${SECTOR}' " -- double quote followed by single quote -- awk matches... (1 Reply)
I want to search a small string in a large string and find the locations of the string. For this I used grep "string" -ob <file name where the large string is stored>. Now this gives me the locations of that string. Now how do I store these locations in a text file.
Please use CODE tags as... (7 Replies)
I will start with an example of what I'm trying to do and then describe how I am approaching the issue.
File
PS028,005
Lexeme HRS # M #
PhraseType 1(1:1) 7(7)
PhraseLab 501 503
ClauseType ZYq0
PS028,005
Lexeme W # L> # BNH # M #... (17 Replies)
Discussion started by: jvoot
17 Replies
LEARN ABOUT NETBSD
strndup
STRDUP(3) BSD Library Functions Manual STRDUP(3)NAME
strdup, strndup -- save a copy of a string
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <string.h>
char *
strdup(const char *str);
char *
strndup(const char *str, size_t len);
DESCRIPTION
The strdup() function allocates sufficient memory for a copy of the string str, does the copy, and returns a pointer to it. The pointer may
subsequently be used as an argument to the function free(3).
If insufficient memory is available, NULL is returned.
The strndup() function copies at most len characters from the string str always NUL terminating the copied string.
EXAMPLES
The following will point p to an allocated area of memory containing the nul-terminated string "foobar":
char *p;
if ((p = strdup("foobar")) == NULL) {
fprintf(stderr, "Out of memory.
");
exit(1);
}
ERRORS
The strdup() function may fail and set the external variable errno for any of the errors specified for the library function malloc(3).
SEE ALSO free(3), malloc(3), strcpy(3), strlen(3)STANDARDS
The strdup() function conforms to IEEE Std 1003.1-2001 (``POSIX.1'').
HISTORY
The strdup() function first appeared in 4.4BSD. The strndup() function was added in NetBSD 4.0.
BSD January 28, 2009 BSD