LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-30-2005, 10:21 AM   #16
Duudson
Member
 
Registered: Dec 2004
Distribution: RHEL3, FC3
Posts: 53

Rep: Reputation: 15

Quote:
Originally posted by jlliagre
You're missing something, "dirname $0" can return a relative or no path at all ".", while pwd will always show a full path: what the OP wants.
That's true. I quess that you could still take that variable away from your script, like this:
Code:
echo $(cd $(dirname $0);pwd)
 
Old 01-30-2005, 10:32 AM   #17
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Sure you can.
 
Old 01-31-2005, 05:37 AM   #18
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
Well, if you absolutely positively must have the directory name in full, this should work:
Code:
 (c=$(which $0);cd ${c%${c##*/}};pwd -P)
bash or ksh.
 
Old 01-31-2005, 11:22 AM   #19
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
which has no advantage over:
Code:
(cd $(dirname $0);pwd)
and is non portable (pwd -P ?)
 
Old 02-01-2005, 03:45 AM   #20
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
true.

pwd -P
korn shell bash built-in.
it works on solaris.
ok then /usr/bin/pwd

what was the question again?
I think the OP may have died
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script's name doesn't appear in ps ealdaz Linux - General 12 08-21-2005 09:27 PM
Log all of a shell script's I/O to the console and a file trevelluk Programming 8 04-18-2005 01:40 PM
uid battle: Apache v/s script's owner kires Linux - Networking 3 01-19-2004 03:43 PM
locating linux config files and how to modify a bash kernel maelstrombob Linux - Newbie 1 11-18-2003 09:56 PM
Problem locating Network script's path f00lday Linux - Networking 3 06-05-2003 04:36 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration