given a relative path, how do i convert it into a full one. i.e. if i am in
/home/polypus
and i am given foo/bar then to get a full path i can just concatinate it with pwd, but what if i am given "../mama"
how do i programmatically convert:
/home/polypus and ../mama into ... (4 Replies)
I have a text file with full list of files with their full path. I wanted to sort it by directory then files then subdirectory by alphabetically. When I used the sort command it doesn't give like what I want. Could somebody help me on this.
Here is the ex:
This is what I'm getting... (2 Replies)
Hi! I need to get PID of some particular process and I wonder if I can use pgrep tool for this purpose. The problem is that pgrep doesn't perform pattern matching on the whole command line, even if I use -f key. Parsing output of ps command is not quite convenient... Also deamon, which PID I need... (2 Replies)
Hi,
I have a file abcd.txt which has contents in the form of full path file names i.e.
$home> vi abcd.txt
/a/b/c/r1.txt
/q/w/e/r2.txt
/z/x/c/r3.txt
Now I want to retrieve only the directory path name for each row
i.e
/a/b/c/
/q/w/e/
How to get the same through shell script?... (7 Replies)
Hi,
Is there a command that tells you right away the current working directory? I know the command "pwd", but that one gives the full path.
if pwd gives me:
/a/b/c/d/ggg/HERE
I want something that will give me:
HERE
Thanks,
Gaurab (13 Replies)
Hey
I'm new to the forums here, and I'm seeking help for this script that I'm writing. When I do ls -l of a directory it shows the full pathname for files in it. For example, if the directory is /internet/post/forum/ and the file is topic, it currently shows internet/post/forum/topic. What's the... (3 Replies)
My input is as below :
/splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt
/splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt
/splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt
/splunk/scrubbed/triumph/ifind.triumph.txt
From the above input I want to extract the file names only .
Basically I want to... (5 Replies)
What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies
LEARN ABOUT SUNOS
dirname
dirname(3C) Standard C Library Functions dirname(3C)NAME
dirname - report the parent directory name of a file path name
SYNOPSIS
#include <libgen.h>
char *dirname(char *path);
DESCRIPTION
The dirname() function takes a pointer to a character string that contains a pathname, and returns a pointer to a string that is a pathname
of the parent directory of that file. Trailing '/' characters in the path are not counted as part of the path.
If path does not contain a '/', then dirname() returns a pointer to the string "." . If path is a null pointer or points to an empty
string, dirname() returns a pointer to the string "." .
RETURN VALUES
The dirname() function returns a pointer to a string that is the parent directory of path. If path is a null pointer or points to an empty
string, a pointer to a string "." is returned.
ERRORS
No errors are defined.
EXAMPLES
Example 1: Changing the Current Directory to the Parent Directory.
The following code fragment reads a pathname, changes the current working directory to the parent directory of the named file (see
chdir(2)), and opens the file.
char path[[MAXPATHLEN], *pathcopy;
int fd;
fgets(path, MAXPATHLEN, stdin);
pathcopy = strdup(path);
chdir(dirname(pathcopy));
fd = open(basename(path), O_RDONLY);
Example 2: Sample Input and Output Strings for dirname().
In the following table, the input string is the value pointed to by path, and the output string is the return value of the dirname() func-
tion.
+-----------------------------+-----------------------------+
| Input String | Output String |
+-----------------------------+-----------------------------+
|"/usr/lib"" |"/usr" |
+-----------------------------+-----------------------------+
|"/usr/" |"/" |
+-----------------------------+-----------------------------+
|"usr" |"/" |
+-----------------------------+-----------------------------+
|"/" |"/" |
+-----------------------------+-----------------------------+
|"." |"." |
+-----------------------------+-----------------------------+
|".." |"." |
+-----------------------------+-----------------------------+
USAGE
The dirname() function modifies the string pointed to by path.
The dirname() and basename(3C) functions together yield a complete pathname. The expression dirname(path) obtains the pathname of the
directory where basename(path) is found.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO basename(1), chdir(2), basename(3C), attributes(5), standards(5)SunOS 5.10 18 Mar 2002 dirname(3C)