LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-26-2004, 07:53 AM   #1
sneezesnoeze
LQ Newbie
 
Registered: Mar 2004
Posts: 15

Rep: Reputation: 0
pwd and the directory above


Hi

I am looking for a command that gives the parent directory of a directory.

for example

home/sneezesnoeze

pwd
the result would be /home/sneezesnoeze

I am looking for a command that gives "/home" as result

does anyone know

kind regards

sneezesnoeze
 
Old 03-26-2004, 08:03 AM   #2
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
cd .. ; pwd ; cd -

You could make an alias for it if you want a one-word command.

John
 
Old 03-26-2004, 08:13 AM   #3
sneezesnoeze
LQ Newbie
 
Registered: Mar 2004
Posts: 15

Original Poster
Rep: Reputation: 0
Is there really no command for it or maybe parameter ?
 
Old 03-26-2004, 08:18 AM   #4
jkobrien
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slackware, LFS, Ubuntu, RedHat, Slamd64
Posts: 507

Rep: Reputation: 30
"man pwd" will answer that for you.

What I suggested above doesn't seem to work so nicely in bash.

This will do it too.

pwd | sed 's/\/[^\/]*$//'

John
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
reset pwd to root's current pwd? ataraktos2 Linux - General 10 04-26-2005 05:13 AM
pwd problem naren Programming 1 04-01-2004 05:52 AM
how to cd to the previously used directory that is no where close to the pwd rootyard Linux - General 3 03-06-2004 11:49 PM
long directory and pwd luegner Slackware 4 11-21-2003 01:57 AM
pwd Penguin666 Linux - General 1 11-19-2003 08:54 PM


All times are GMT -5. The time now is 09:43 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration