Kwissle

My real-time quiz battle game Kwissle.com

Crosstips.org

My fun Crossword solver project. Crosstips.org & Krysstips.se

Kung Fu

Fujian White Crane Kung Fu

Photos

Photoalbum, both old and new.

Twitter

Follow me on Twitter

Contact me

My contact details and how to contact me.

 

KungFuPeople.com
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com


Mobile version of this page Mobile version of this page


 
Linux

pwdf - a mix of ls and pwd


7th of April 2008

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?



Comment

Pete - 14th May 2008  [«« Reply to this]
If you are using bash, you can use
echo $PWD/todo.sh
Samat Jain - 27th July 2011  [«« Reply to this]
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
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.