MEMMEM(3) Linux Programmer's Manual MEMMEM(3)NAME
memmem - locate a substring
SYNOPSIS
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <string.h>
void *memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
DESCRIPTION
The memmem() function finds the start of the first occurrence of the substring needle of length needlelen in the memory area haystack of
length haystacklen.
RETURN VALUE
The memmem() function returns a pointer to the beginning of the substring, or NULL if the substring is not found.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+----------+---------------+---------+
|Interface | Attribute | Value |
+----------+---------------+---------+
|memmem() | Thread safety | MT-Safe |
+----------+---------------+---------+
CONFORMING TO
This function is not specified in POSIX.1, but is present on a number of other systems.
BUGS
In glibc 2.0, if needle is empty, memmem() returns a pointer to the last byte of haystack. This is fixed in glibc 2.1.
SEE ALSO bstring(3), strstr(3)COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
GNU 2017-03-13 MEMMEM(3)
Check Out this Related Man Page
MEMMEM(3) Linux Programmer's Manual MEMMEM(3)NAME
memmem - locate a substring
SYNOPSIS
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <string.h>
void *memmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
DESCRIPTION
The memmem() function finds the start of the first occurrence of the substring needle of length needlelen in the memory area haystack of
length haystacklen.
RETURN VALUE
The memmem() function returns a pointer to the beginning of the substring, or NULL if the substring is not found.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+----------+---------------+---------+
|Interface | Attribute | Value |
+----------+---------------+---------+
|memmem() | Thread safety | MT-Safe |
+----------+---------------+---------+
CONFORMING TO
This function is not specified in POSIX.1, but is present on a number of other systems.
BUGS
In glibc 2.0, if needle is empty, memmem() returns a pointer to the last byte of haystack. This is fixed in glibc 2.1.
SEE ALSO bstring(3), strstr(3)COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
GNU 2017-03-13 MEMMEM(3)
Hello,
I need to locate the last occurrence of a substring in a given string.NULL is returned if the substring is not found in the stringhow do i do this with a sed command..? (0 Replies)
hi all, I'm really newbie on this and I need some help.
how is the best way to extract a strig or substring from a each line in a file.
e.g. I want to print only this ERROR=JUD+the followed numbers from one line like this one, considering the numbers change related to different errors
... (1 Reply)
I have two files:
One is a list of numbers:
1
5
6
7
10
The second is a very long string
abcdefghijklmno......1234567890
I'd like to print a new file with a 5 character substring that starts at each the positions listed in the 1st file:
such as:
abcde (4 Replies)
I am trying something like below. But unfortunately i am missing sthg here.
$ HOSTEXT=hostname | awk '{print substr ($0,7)}'
$ echo $HOSTEXT
$
Suggestioins/Solutions will very much be appreciated.
Thanks in advance,
best-dyno. (2 Replies)
Hi,
I'm new to HP-UNIX programming(previously using C++). I am looking for an IF statement which would return TRUE if a substring is found in a string.
For example, if 'header' is found in 'header_cp', the IF statement will result to true.
Would appreciate any help... (1 Reply)
hi
i need to name a file with a substring of a another file name.
i.e. if the old filename is abc.txt , the new filename should be abc_1.txt
i should get the substring of the file name and then name the new one
please let me know how to do it (4 Replies)
I retrieved values from postgresql database
return the following line
name ------------ myname (1 row)
how can I extract "myname" out of the line?
thanks (11 Replies)
Hi,
Please let me know how to perform the substring operation in kshell.
If i have line like below
238923893282389034893489458945904589045454903490
i would like to retrieve the position 7 to 19, how to do this in kshell? (1 Reply)
Hi guys,
I am trying to remove lines that have a duplicate substring from any part in the file. So, for ex:
433043950359.3 5033 305935 2 2dd 5ffgs DOG43453552.A
3443565634 95460 3435 45 23d 56ggh DOG343211
3423895702359 34 66699 9455 2324 DOG43453552.B
This is a very large file, and... (1 Reply)
I am new to awk and writing a script using awk. I have file containing fixed length records, I wish to extract 2 substring(each substring is padded with zeros on left e.g 000000003623) and add each substring respectively for every record in the file to get total sum of respective substring for all... (5 Replies)
I'm attempting to replace a substring that contains a hyphen and not having much success, can anyone point out where i'm going wrong or suggest an alternative.
# echo /var/lib/libvirt/images/vm888b-clone.qcow | sed -e 's|vm888-clone|qaz|g'
/var/lib/libvirt/images/vm888b-clone.qcow (1 Reply)
I want to merge the lines by matching substring of the first file with first column of the second file.
file1:
S00739A_ACAGTG_L001_R1.fq.gz
S00739A_ACAGTG_L001_R2.fq.gz
S00739B_GCCAAT_L001_R1.fq.gz
S00739B_GCCAAT_L001_R2.fq.gz
S00739D_GTGAAA_L001_R1.fq.gz
S00739D_GTGAAA_L001_R2.fq.gz... (14 Replies)