12-18-2009
This statement makes me think it's a homework:
Quote:
4) P.S. Using shell commands only. Something like realpath() call for C.
Why only shell commands?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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)
Discussion started by: chebarbudo
5 Replies
2. UNIX for Dummies Questions & Answers
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)
Discussion started by: ordano
1 Replies
3. Shell Programming and Scripting
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)
Discussion started by: royzlife
7 Replies
4. Shell Programming and Scripting
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)
Discussion started by: pstein
1 Replies
5. Shell Programming and Scripting
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)
Discussion started by: gogok_bg
6 Replies
6. Shell Programming and Scripting
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)
Discussion started by: Aswex
1 Replies
7. UNIX for Dummies Questions & Answers
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)
Discussion started by: IshuGupta
5 Replies
8. UNIX for Dummies Questions & Answers
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)
Discussion started by: tara123
1 Replies
9. UNIX for Beginners Questions & Answers
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)
Discussion started by: Sekhar419
4 Replies
10. UNIX for Beginners Questions & Answers
What is the difference ../directory path and ./directory path in ksh? (1 Reply)
Discussion started by: TestKing
1 Replies
LEARN ABOUT SUSE
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.25 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)