Do the commands realpath or readlink (with or without -f) help here at all?
Or perhaps the Cwd module from perl:
I have tried the following where dpi.txt is a file in /home/user_name
All of these result in /home/user_name/dpi.txt
The perl code output looked a bit odd be seemed to print the same thing. The readlink command gave the same results a realpath.
It looks like findmnt may give me what I need. Skipping allot of stuff,
This seems to indicate that /home is located on /dev/sdb3/01_centos , which is /mnt/linux_data/01_centos which is expected.
LMHmedchem
Last edited by LMHmedchem; 03-03-2020 at 12:28 AM..
Is it unsafe to put your own home directory (a regular user) in your search path? I am writing useful shell scripts, but don't have the permissions to put them in /usr/bin. (Korn shell)
thanks (2 Replies)
Hi guys
I'm trying to move an empty directory to the $TRASH directory. Say the directory i have is ./hello/hello1/hello2 and i'm in hello2, and i want hello2 moved.
this code:
TRASH=$home/deleted
find "$TRASH/$1" -type d -exec rmdir { } \; 2>/dev/null
mv -f $1 $TRASH 2>/dev/null
works... (2 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 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)
I'm running AIX unix korn shell. If I echo $0, I only get the filename, it does not have the directory name also. So when I do: `dirname $0` it returns a . (meaning current directory). How get $0 to return the full path/filename? Do I need something in my .profile? Thank you. (8 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)
Hi
I have a requirement like this:
/abc/a/x.txt
/abc/a/y.txt
/abc/b/x.gz
/abc/b/y.txt
I need output like this:
/abc/a:*.txt
/abc/b:*.txt
/abc/b:*.gz
I have tried find /abc -type f -name "*.*" ||awk -F . '{print $NF}' it is print only extensions without path name.
Please... (5 Replies)
Discussion started by: lijjumathew
5 Replies
LEARN ABOUT OSX
realpath
REALPATH(3) BSD Library Functions Manual REALPATH(3)NAME
realpath -- returns the canonicalized absolute pathname
SYNOPSIS
#include <stdlib.h>
char *
realpath(const char *restrict file_name, char *restrict resolved_name);
DESCRIPTION
The realpath() function resolves all symbolic links, extra ``/'' characters, and references to /./ and /../ in file_name. If the
resolved_name argument is non-NULL, the resulting absolute pathname is copied there (it must refer to a buffer capable of storing at least
PATH_MAX characters).
As a permitted extension to the standard, if resolved_name is NULL, memory is allocated for the resulting absolute pathname, and is returned
by realpath(). This memory should be freed by a call to free(3) when no longer needed.
The realpath() function will resolve both absolute and relative paths and return the absolute pathname corresponding to file_name. All com-
ponents of file_name must exist when realpath() is called.
RETURN VALUES
On success, the realpath() function returns the address of the resulting absolute pathname, which is resolved_name if it was non-NULL, or the
address of newly allocated memory. If an error occurs, realpath() returns NULL. If resolved_name was non-NULL, it will contains the path-
name which caused the problem.
VARIANTS
Defining _DARWIN_C_SOURCE or _DARWIN_BETTER_REALPATH before including stdio.h will cause the provided implementation of realpath() to use
F_GETPATH from fcntl(2) to discover the path.
ERRORS
The function realpath() may fail and set the external variable errno for any of the errors specified for the library functions alloca(3),
getattrlist(2), getcwd(3), lstat(2), readlink(2), stat(2), and strdup(3).
LEGACY SYNOPSIS
#include <sys/param.h>
#include <stdlib.h>
The include file <sys/param.h> is necessary.
LEGACY DESCRIPTION
In legacy mode, the last component of file_name does not need to exist when realpath() is called.
SEE ALSO free(3), getcwd(3), compat(5)HISTORY
The realpath() function first appeared in 4.4BSD.
BSD April 5, 2008 BSD