Your question made be think about the real reason... Hm...
I found that I don't know how to retrieve full real path in shell and it confused me. Of course, I can write something like
in C++ program and use it. But it is not a solution for each system, where our additional binary is missed. Say at my friend home
---------- Post updated at 09:36 PM ---------- Previous update was at 09:29 PM ----------
Quote:
Originally Posted by tlarkin
ls does it for me
bolded shows the parent folder. I am not using standard Unix though, I am using OS X. Might be some differences.
So the 1st way I can see is to use something like
It isn't graceful way, don't you think so? As for me: it is usable but depends on ls standard, and possible differences between UNIX systems. Doesn't it?
Hi there,
Is there any way to obtain a real path from a weird path. For example :
/foo/../bar/ -> /bar/
/foo/. -> /foo/
Thanks in advance
Santiago (5 Replies)
If I the path to a directory, what command can I use to return the actual name of that directory.
test=`pwd`/folder1
> $test
folder1
I'd rather avoid anything with regular expressions. Any ideas? (1 Reply)
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)
If I enter (simplified):
find . -printf "%p\n"
then all files in the output are prepended by a "." like
./local/share/test23.log
How can achieve that
a.) the leading "./" is omitted
and/or
b.) the full path to the current directory is inserted (enclosed by brackets and a blank)... (1 Reply)
I have directory with shorcuts of files.
for example:
gara@yn\short\name1 ( shortcut to gara@yn\FOLDER\OPT\GARA\1.jpg )
gara@yn\short\name2 ( shortcut to gara@yn\FOLDER\OPT\GARA\11.jpg )
gara@yn\short\name3 ( shortcut to gara@yn\MARA\URSA\2.jpg )
gara@yn\short\name4 ( shortcut to... (6 Replies)
Hello,
I am looking for a command that will give me the last directory name from a path
ex 1 :
/dir1/dir/2/dir3/
output needed
dir3
ex 2 :
/dir1/dir/2/dir3/dir4/
output needed
dir4 (1 Reply)
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)
Hello,
I need download a mp3 file from a site but I can not find the actual link. Thanks.
Source codes
<span title="what is" class="read"><embed type="application/x-shockwave-flash" src="au/audio.swf" width="17" height="13" align="texttop" quality="high" loop="false" menu="false"... (1 Reply)
Hello,
I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies
LEARN ABOUT LINUX
symlinkat
SYMLINKAT(2) Linux Programmer's Manual SYMLINKAT(2)NAME
symlinkat - create a symbolic link relative to a directory file descriptor
SYNOPSIS
#include <fcntl.h> /* Definition of AT_* constants */
#include <stdio.h>
int symlinkat(const char *oldpath, int newdirfd, const char *newpath);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
symlinkat():
Since glibc 2.10:
_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
Before glibc 2.10:
_ATFILE_SOURCE
DESCRIPTION
The symlinkat() system call operates in exactly the same way as symlink(2), except for the differences described in this manual page.
If the pathname given in newpath is relative, then it is interpreted relative to the directory referred to by the file descriptor newdirfd
(rather than relative to the current working directory of the calling process, as is done by symlink(2) for a relative pathname).
If newpath is relative and newdirfd is the special value AT_FDCWD, then newpath is interpreted relative to the current working directory of
the calling process (like symlink(2)).
If newpath is absolute, then newdirfd is ignored.
RETURN VALUE
On success, symlinkat() returns 0. On error, -1 is returned and errno is set to indicate the error.
ERRORS
The same errors that occur for symlink(2) can also occur for symlinkat(). The following additional errors can occur for symlinkat():
EBADF newdirfd is not a valid file descriptor.
ENOTDIR
newpath is relative and newdirfd is a file descriptor referring to a file other than a directory.
VERSIONS
symlinkat() was added to Linux in kernel 2.6.16.
CONFORMING TO
POSIX.1-2008.
NOTES
See openat(2) for an explanation of the need for symlinkat().
SEE ALSO openat(2), symlink(2), path_resolution(7), symlink(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/.
Linux 2009-12-13 SYMLINKAT(2)