LinuxQuestions.org
Visit Jeremy's Blog.
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 06-09-2004, 05:31 AM   #1
facets
LQ Newbie
 
Registered: May 2004
Distribution: Fedora Core 2 / Damnsmalllinux
Posts: 18

Rep: Reputation: 0
PWD question : Current dir not full path


Hey Gang,

Dumb question I know.. But i can't nut it out.

pwd gives me

/home/work/test
/usr/files/386

I only want to know what dir i'm in. So answer is test or 386
I know I need to pipe this through SED perhaps but can't work it out...

Ideas?

Cheers, M.
 
Old 06-09-2004, 05:55 AM   #2
rkef
Member
 
Registered: Mar 2004
Location: bursa
Posts: 110

Rep: Reputation: 15
Code:
pwd | awk -F/ '{print $NF}'
 
Old 06-09-2004, 05:58 AM   #3
facets
LQ Newbie
 
Registered: May 2004
Distribution: Fedora Core 2 / Damnsmalllinux
Posts: 18

Original Poster
Rep: Reputation: 0
Also found

pwd | sed 's/.*\///'

works too.
Cheers, M.
 
  


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
su - and stay in current dir lord-fu Linux - Newbie 2 11-16-2005 09:08 AM
question about putting pwd in $PATH nadroj Linux - Newbie 5 05-30-2005 05:34 PM
reset pwd to root's current pwd? ataraktos2 Linux - General 10 04-26-2005 05:13 AM
Apache: making a dir with username and pwd fledermaus Linux - Networking 1 05-13-2004 10:40 AM
How xterm get known that current dir changed? pvv Programming 3 03-15-2004 09:27 AM

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

All times are GMT -5. The time now is 04:00 AM.

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