Determine path of file
- From: Kenneth Brun Nielsen <kenneth.brun.nielsen@xxxxxxxxxxxxxx>
- Date: Mon, 4 Feb 2008 08:04:03 -0800 (PST)
I reference a file from a script through command line parameters.
I.e.
script.sh [referenced file]
The file can be refered to as both absolute and relative path. How can
I easily get the complete (absolute) path independent on whether it is
specified absolute or relative.
I tried with addition of $pwd, but in case of an absolute reference I
run into problems with two consecutive slashes, e.g. /home/kbn/path//
home/kbn/path/file
At the moment I use sed, but I assume some more easy/pretty solutions
exist(?)
Best regards,
Kenneth (the number-one-question-maker)
.
- Follow-Ups:
- Re: Determine path of file
- From: Stephane Chazelas
- Re: Determine path of file
- Prev by Date: Re: BASH variable scope
- Next by Date: Re: Determine path of file
- Previous by thread: BASH variable scope
- Next by thread: Re: Determine path of file
- Index(es):
Relevant Pages
|