Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

memmem(3) [x11r4 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)

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)
Man Page

12 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using sed command...

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)
Discussion started by: sharsin2001
0 Replies

2. UNIX for Dummies Questions & Answers

how to extract a substring froma file

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)
Discussion started by: morena
1 Replies

3. Shell Programming and Scripting

Calling a substring from another file

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)
Discussion started by: dcfargo
4 Replies

4. UNIX for Dummies Questions & Answers

how to take the substring value into a variable

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)
Discussion started by: best-dyno
2 Replies

5. UNIX for Dummies Questions & Answers

Verify if substring is found in string

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)
Discussion started by: miashaykoh
1 Replies

6. Shell Programming and Scripting

extracting substring from a file name

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)
Discussion started by: adityamahi
4 Replies

7. Shell Programming and Scripting

Get information like substring

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)
Discussion started by: uativan
11 Replies

8. Shell Programming and Scripting

Substring operation in kshell

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)
Discussion started by: informsrini
1 Replies

9. UNIX for Dummies Questions & Answers

removal by substring

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)
Discussion started by: verse123
1 Replies

10. Shell Programming and Scripting

Add substring in a file containing fixed length record.

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)
Discussion started by: Devesh5683
5 Replies

11. Shell Programming and Scripting

sed - replacing a substring containing a hyphen

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)
Discussion started by: squrcles
1 Replies

12. Shell Programming and Scripting

Match substring from a column of the second file

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)
Discussion started by: yifangt
14 Replies