Learn about Linux
Download Linux
Get Linux help
Get special offers on:
Linux Application Dev Programming Software
Email:
#
Return to Four ways to extract the current directory name
© Copyright 1999-2008 - SourceForge, Inc., All Rights Reserved About Linux.com - Privacy Statement - Terms of Use - Advertise - Trademark - Ask Linux Questions - Write for Us - RSS Feed ThinkGeek - Slashdot - SourceForge.net - freshmeat - Surveys - Jobs
Four ways to extract the current directory name
Posted by: Anonymous [ip: 147.88.200.144] on November 06, 2007 12:29 PMpwd | rev | awk –F \/ '{print $1}' | rev
would be
pwd | awk -F \/ '{ print $NF }'
awk knows the variable $NF which contains the "number of fields" so { print $NF } gives you the last field
just my 2¢
#