Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

memmem(3) [netbsd man page]

MEMMEM(3)						   BSD Library Functions Manual 						 MEMMEM(3)

NAME
memmem -- locate substring in byte string LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <string.h> void * memmem(const void *block, size_t blen, const void *pat, size_t plen); DESCRIPTION
The memmem() function locates the first occurrence of the binary string pat of size plen bytes in the byte string block of size blen bytes. RETURN VALUES
The memmem() function returns a pointer to the substring located, or NULL if no such substring exists within block. If plen is zero, block is returned, i.e. a zero length pat is deemed to match the start of the string, as with strstr(3). SEE ALSO
bm(3), memchr(3), strchr(3), strstr(3) STANDARDS
The memmem() function is not currently standardized. However, it is meant to be API compatible with functions in FreeBSD and Linux. HISTORY
memmem() first appeared in the Free Software Foundation's glibc library. BSD
March 12, 2005 BSD

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

15 More Discussions You Might Find Interesting

1. Programming

can i get a substring from a string?

for example, the string a is "abcdefg", can i get a substring "bcd" (from ato a) from string a? thank you (4 Replies)
Discussion started by: dell9
4 Replies

2. Shell Programming and Scripting

Getting substring from parameter

I would like to get a substring of a string in command line, for example I would like to turn the string 123456789_bla.txt to bla It would be also great to find the postition of a certain characer in a "_" string: 123456789_bla.txt to 10 I hope someone can understand my... (2 Replies)
Discussion started by: slobodan
2 Replies

3. UNIX for Dummies Questions & Answers

How to get the substring from the string

Hi All, Can anybody help me to get the substring from the given string. (3 Replies)
Discussion started by: Anshu
3 Replies

4. UNIX for Dummies Questions & Answers

substring using AWK

can we do substring fuctionality using AWK say I have string "sandeep" can i pick up only portion "nde" from it. Thanks and Regards Sandeep Ranade (3 Replies)
Discussion started by: mahabunta
3 Replies

5. UNIX for Dummies Questions & Answers

Substring not working if more than 1 space

I have a string which is something like this.. abcd efghijkl when I use this using substring() function 2 spaces are bein considered as one starngely. Is there any thing I am doing wroing the input file maintest has the string specified and the code is below while read... (3 Replies)
Discussion started by: prassu
3 Replies

6. Shell Programming and Scripting

Perl, string manipulation

Hi all, Supposing the following string: XXXXXXXXXXNEAXXXXXX How can I check if this string has the substring NEA? Best regards Chris (3 Replies)
Discussion started by: chriss_58
3 Replies

7. Shell Programming and Scripting

How to grep substring from a line ?

Hi all, I am stuck in a tricky situation where i want to search a substring from a line through shell script.What i meant by that is given in the example shown below: Line :: This is the TEST(Message(with some tricky word)) from which i want to search. Result substring should be :... (8 Replies)
Discussion started by: titanicstarin
8 Replies

8. UNIX for Dummies Questions & Answers

Word Count (WC) command

I have created a file "pat".This file contains the text "abcdefghi". Now i want to count the characters in this file "pat". I gave wc -c | pat and it returns me exact count "9". Now when i tried like "echo pat | wc -m" It returns '4'. as for as i understand this command "echo pat | wc -m" should... (7 Replies)
Discussion started by: mdali_vl
7 Replies

9. UNIX for Dummies Questions & Answers

Need help with substring

I need to check the occurrence of one string within another. code ******************** if ;then do something done ******************** Thanks (7 Replies)
Discussion started by: w020637
7 Replies

10. Shell Programming and Scripting

Searching a substring from a string in UNIX

Hi all. I need help with a command to locate a substring from a string. My problem is I am passing a direcotry name as a command line argument and I need to ensure that user should not pass certain directories. E.g ther are Directories under ==> /opt/projects/* which should not be passed... (3 Replies)
Discussion started by: Veenak15
3 Replies

11. Linux

Selecting substring (like SQL Server function)

Hey, geniuses of the world (no--facetious is NOT the word of the day;))! I was wondering if there's a way to extract a specific portion from a string of characters in UNIX/LINUX. Give me the generic capabilities (assuming they exist) and I'll figure out the small details. But if you know... (8 Replies)
Discussion started by: ProGrammar
8 Replies

12. Shell Programming and Scripting

how to remove this substring?

Hello, I need to remove a substring from a string in a ksh script, the string is like this: LOCATION=+DATADG1/CMSPRD1/datafile/system.235.456721 or LOCATION=/u03/oradata/CMSPRD/SYSTEM.dbf I need to strip the last file name from that path, and get: +DATADG1/CMSPRD1/datafile or,... (8 Replies)
Discussion started by: seafan
8 Replies

13. UNIX for Dummies Questions & Answers

If statement for substring within string (korn)

Hi all, Just looking for a simple if statement that searches for a substring within a varaible, and then performs some function. Problem is that I need it to work in Korn shell $var = *string* does not work in Korn i="xxxxxx00.00yyyyy.zzzzz" want to find 00.00 (2 Replies)
Discussion started by: jgrosecl
2 Replies

14. Shell Programming and Scripting

sed with variables

Im trying to use sed to print value that matches the value in variable and all lines after that. grep "Something" test.txt | sed -e '/{$variable}/,$b' -e 'd' I cant get it work, if I replace the $variable with the value it contains, it works fine... (10 Replies)
Discussion started by: olkkis
10 Replies

15. UNIX for Beginners Questions & Answers

Check if string contains substring surrounded by numbers

Hi, I have a process that generates strings. I would like to check each string and search for substring which contains the letter 'E' surrounded by numbers (both sides of the letter 'E'). few examples: AA4E7012A2 - contains E surrounded by numbers FE18274012 - does not contain E... (3 Replies)
Discussion started by: yanive
3 Replies