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)
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)
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)
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)
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)
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)
I need to check the occurrence of one string within another.
code
********************
if ;then do something done
********************
Thanks (7 Replies)
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)
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)
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)
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)
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)
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)