pwdf - a mix of ls and pwd

07 April 2008   2 comments   Linux

Mind That Age!

This blog post is 10 years old! Most likely, its content is outdated. Especially if it's technical.

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 todo.sh 
/home/peterbe/bin/todo.sh

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

#!/bin/bash
echo -n `pwd`
echo -n '/'
echo $1

Is there no easier way built in into Linux already?

Comments

Pete

If you are using bash, you can use
echo $PWD/todo.sh

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

[1]: http://unixhelp.ed.ac.uk/CGI/man-cgi?readlink

Your email will never ever be published


Related posts

Previous:
Lesson learnt with creating DOM element with jQuery 04 April 2008
Next:
Mixing in new-style classes in Zope 2.7 09 April 2008
Related by Keyword:
How to NOT start two servers on the same port 11 June 2018
How I found out where a bash alias was set up 09 May 2018
Run something forever in bash until you want to stop it 13 February 2018
A neat trick to zip a git repo with a version number 01 September 2017
And bash basics 16 October 2015
Related by Text:
jQuery and Highslide JS 08 January 2008
I'm back! Peterbe.com has been renewed 05 June 2005
Anti-McCain propaganda videos 12 August 2008
Ever wondered how much $87 Billion is? 04 November 2003
Guake, not Yakuake or Yeahconsole 23 January 2010