pwdf - a mix of ls and pwd

07 April 2008   2 comments   Linux

Powered by Fusion×

I often need to know the path to a file so that I can put that in an email for example. The only way I know is to copy and paste the output of pwd followed by a slash / followed by the name of the file. This is too much work so I wrote a quick bash script to combine this into one. Now I can do this:

$ cd bin
$ pwdf 

I call it pwdf since it's pwd + file. Here's the code for the curious:

echo -n `pwd`
echo -n '/'
echo $1

Is there no easier way built in into Linux already?


If you are using bash, you can use
echo $PWD/
Samat Jain
Not sure if it was part of GNU coreutils when you wrote this, but there's readlink[1]. Use:

readlink -f the-file


Your email will never ever be published

Related posts

Lesson learnt with creating DOM element with jQuery 04 April 2008
Mixing in new-style classes in Zope 2.7 09 April 2008
Related by keywords:
Read in passwords with bash 25 March 2005
set -ex - The most useful bash trick of the year 31 August 2014
How I do deployments 16 December 2013
Catching a carriage return in bash 23 October 2006
ztar - my wrapper on tar -z 29 June 2005
Bash tip of the day: ff 25 March 2011
FacebookStatusUpdater 07 June 2007
File check before delete 07 March 2008
type - Writing shell scripts 28 April 2006