Hi All,
I have a string like "9633C01302_2". I need to extract the number(02) after "13" and before "_" and the number coming after "13" and before "_" is not constant, it keeps on changing...
Can some one plz help me wth the command..
i tried this echo "9633C01302_2" | cut -d'_' -f1 ..But... (2 Replies)
Not sure if the title of this thread makes sense, but hopefully my explanation will.
I'm using awk to print some stats from an apache accesslog. I would like to specify the regexp condition where only the two root pages of "index.html" and "/" are counted in my results. What I can't figure out... (3 Replies)
Hello People,
I have the following contents in an XML file
...........
...........
..........
...........
<Details = "Sample Details">
<Name>Bob</Name>
<Age>34</Age>
<Address>CA</Address>
<ContactNumber>1234</ContactNumber>
</Details>
...........
.............
.............. (4 Replies)
Hi ,
I have below file with 13 columns. I need 2-13 columns seperated by comma and I want to append each row with a string "INSERT INTO xxx" in the begining as 1st column and then a variable "$node" and then $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13 and at the end another string " ; COMMIT;"
... (4 Replies)
Dear Members,
Depending on the current date i should find out the start and end dates of the quarter.
ex: Today date is 14-Nov-2011 then Quarter start date should be Oct 1 2011 and Quarter End date should be Dec 31 2011.
How can i do this?
Thanks
Sandeep (1 Reply)
I am trying to extract a string from a line of text. Currently I am using
grep -o 'startofstring(.........'
The string is not always the same size.
The string I'm trying to extract starts with 'test(' ends with ')'.
ex "blah,blah,blah,test(stringoftext),blah blah"
How do I... (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'm trying to stop reading a file until the end of the file is reached or a defined delimiter line is reached. Some how I need to test the fail state of the last 2 commands, not just the last command.
echo -e "hello\ngoodbye\n####\ntesting" | while read line; ]; do echo "$line"; done
hello... (4 Replies)
I have a file as follows:
0
1056
85540
414329
774485
1208487
1657519
2102753
2561259
3037737
3458144
3993019
4417959
4809964
5261890
5798778
6254146
I want to find all lines between a specified start and end tag. (6 Replies)
Hi,
I have a scenario where I want to display the output based on the pattern search between the start and end of a block in a file, we can have multiple start and end blocks in a file.
Example give below, we need to search between the start block abc and end block def in a file, after that... (5 Replies)
Discussion started by: G.K.K
5 Replies
LEARN ABOUT LINUX
basename
BASENAME(3) Linux Programmer's Manual BASENAME(3)NAME
basename, dirname - parse pathname components
SYNOPSIS
#include <libgen.h>
char *dirname(char *path);
char *basename(char *path);
DESCRIPTION
Warning: there are two different functions basename() - see below.
The functions dirname() and basename() break a null-terminated pathname string into directory and filename components. In the usual case,
dirname() returns the string up to, but not including, the final '/', and basename() returns the component following the final '/'. Trail-
ing '/' characters are not counted as part of the pathname.
If path does not contain a slash, dirname() returns the string "." while basename() returns a copy of path. If path is the string "/",
then both dirname() and basename() return the string "/". If path is a NULL pointer or points to an empty string, then both dirname() and
basename() return the string ".".
Concatenating the string returned by dirname(), a "/", and the string returned by basename() yields a complete pathname.
Both dirname() and basename() may modify the contents of path, so it may be desirable to pass a copy when calling one of these functions.
These functions may return pointers to statically allocated memory which may be overwritten by subsequent calls. Alternatively, they may
return a pointer to some part of path, so that the string referred to by path should not be modified or freed until the pointer returned by
the function is no longer required.
The following list of examples (taken from SUSv2) shows the strings returned by dirname() and basename() for different paths:
path dirname basename
"/usr/lib" "/usr" "lib"
"/usr/" "/" "usr"
"usr" "." "usr"
"/" "/" "/"
"." "." "."
".." "." ".."
RETURN VALUE
Both dirname() and basename() return pointers to null-terminated strings. (Do not pass these pointers to free(3).)
CONFORMING TO
POSIX.1-2001.
NOTES
There are two different versions of basename() - the POSIX version described above, and the GNU version, which one gets after
#define _GNU_SOURCE
#include <string.h>
The GNU version never modifies its argument, and returns the empty string when path has a trailing slash, and in particular also when it is
"/". There is no GNU version of dirname().
With glibc, one gets the POSIX version of basename() when <libgen.h> is included, and the GNU version otherwise.
BUGS
In the glibc implementation of the POSIX versions of these functions they modify their argument, and segfault when called with a static
string like "/usr/". Before glibc 2.2.1, the glibc version of dirname() did not correctly handle pathnames with trailing '/' characters,
and generated a segfault if given a NULL argument.
EXAMPLE
char *dirc, *basec, *bname, *dname;
char *path = "/etc/passwd";
dirc = strdup(path);
basec = strdup(path);
dname = dirname(dirc);
bname = basename(basec);
printf("dirname=%s, basename=%s
", dname, bname);
SEE ALSO basename(1), dirname(1), feature_test_macros(7)COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2009-03-30 BASENAME(3)