Sponsored Content
Top Forums Shell Programming and Scripting Identify full path in argument Post 302932940 by achenle on Monday 26th of January 2015 01:52:48 PM
Old 01-26-2015
You can also just use 'realpath':

realpath(1) - Linux man page
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getting the path part of an argument

Seems I'm inundating this forum with questions, but anyway: I am writing a script that should accept one and only one argument when called. That argument should designate a file, either with path/filename or just filename. Now to the difficult bit: I want to figure out a way to store... (9 Replies)
Discussion started by: ropers
9 Replies

2. Shell Programming and Scripting

getting full path from relative path

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)
Discussion started by: polypus
4 Replies

3. UNIX for Dummies Questions & Answers

Listing files with full path

Hi, I need to store all the files in a directory to a text file with its full path. The example below can explain: ./File1.txt ./File2.txt ./Folder1/File11.txt ./Folder1/File12.txt ./Folder1/Folder11/File111.txt ./Folder2/file21.txt : : The ls -R1 command won't give the result as... (5 Replies)
Discussion started by: r_sethu
5 Replies

4. Shell Programming and Scripting

list file with full path

This has been bugging me for a while. How can i list file to show full path. /directory/test $ ls file.tst file.tst $ desired output: /directory/test/file.tst (2 Replies)
Discussion started by: ryandegreat25
2 Replies

5. Shell Programming and Scripting

Retrieve directory path from full file path through sh

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

6. Shell Programming and Scripting

How to extract strings from full path when full path is not fixed

/Path/snowbird9/nrfCompMgrRave1230100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird6/nrfCompMgrRave1220100920.log.gz:09/20/2010 06:14:51 ERROR Error Message. /Path/snowbird14/nrfCompMgrRave920100920.log.gz:09/20/2010 06:14:51 ERROR Error Message.... (0 Replies)
Discussion started by: Shirisha
0 Replies

7. UNIX for Advanced & Expert Users

Passing full path as argument when it contains variable strings

Hi, In directory "inoutfiles", I have folders fold0001, fold0002 and so on. Every folder has corresponding file file0001.txt, file0002.txt and so on. I want to perform a certain action on multiple files in one go. The cpp file is in the same directory as "inoutfiles". This is my code : ... (0 Replies)
Discussion started by: KidD312
0 Replies

8. Programming

Passing full path as argument when it contains variable strings

Hi, In directory "inoutfiles", I have folders fold0001, fold0002 and so on. Every folder has corresponding file file0001.txt, file0002.txt and so on. I want to perform a certain action on multiple files in one go. The cpp file is in the same directory as "inoutfiles". This is my code : ... (1 Reply)
Discussion started by: KidD312
1 Replies

9. Shell Programming and Scripting

Regex to identify a full-stop as a sentence delimiter

Hello, Splitting a sentence using the full-stop/question-mark/exclamation is a common device. Whereas the question-mark / exclamation do not pose too much of a problem; the full-stop as a sentence delimiter raises certain issues because of its varied use: just to name a few. Standard parsers... (9 Replies)
Discussion started by: gimley
9 Replies

10. Hardware

How to identify virtual/physic disk path on X4100?

Hello, Currently we have a Oracle X4100 ( Solaris 10 ) server with disk failure. Originally our hardware team thought the disk can be hot-swap, when they stood in front of the server, none of the disk failure LED were on, so now we have no idea which disk is the bad one for replacement. As... (2 Replies)
Discussion started by: sunnychen98
2 Replies
explain_realpath_or_die(3)				     Library Functions Manual					explain_realpath_or_die(3)

NAME
explain_realpath_or_die - return canonical pathname and report errors SYNOPSIS
#include <libexplain/realpath.h> char *explain_realpath_or_die(const char *pathname, char *resolved_pathname); char *explain_realpath_on_error(const char *pathname, char *resolved_pathname); DESCRIPTION
The explain_realpath_or_die function is used to call the realpath(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_realpath(3) function, and then the process terminates by calling exit(EXIT_FAILURE). The explain_realpath_on_error function is used to call the realpath(3) system call. On failure an explanation will be printed to stderr, obtained from the explain_realpath(3) function, but still returns to the caller. pathname The pathname, exactly as to be passed to the realpath(3) system call. resolved_pathname The resolved_pathname, exactly as to be passed to the realpath(3) system call. RETURN VALUE
The explain_realpath_or_die function only returns on success, see realpath(3) for more information. On failure, prints an explanation and exits, it does not return. The explain_realpath_on_error function always returns the value return by the wrapped realpath(3) system call. EXAMPLE
The explain_realpath_or_die function is intended to be used in a fashion similar to the following example: char *result = explain_realpath_or_die(pathname, resolved_pathname); SEE ALSO
realpath(3) return the canonicalized absolute pathname explain_realpath(3) explain realpath(3) errors exit(2) terminate the calling process COPYRIGHT
libexplain version 0.52 Copyright (C) 2011 Peter Miller explain_realpath_or_die(3)
All times are GMT -4. The time now is 10:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy