[Ma-linux] Scripting redux Approaching
Michael Henry
lug-user at drmikehenry.com
Mon Mar 14 06:56:29 EDT 2011
On 03/12/2011 07:47 PM, Bruce Israel wrote:
> Jim, that doesn't match my requirements. To be more explicit about
> them, I want to be able to specify a file such that 'cat' or 'ls'
> will work on them, and be able get get the full pathname.
>
> While your script will work with:
>
> cd /etc; JimsScript ./passwd
>
> If I do:
>
> cd ; JimsScript /etc/passwd
>
> I get back /home/israel/passwd, which is NOT the same thing!
Did you try JimsScript? If so, I'm curious why it failed in your testing:
$ cd; JimsScript /etc/passwd
/etc/passwd
$ cat ~/bin/JimsScript
#!/bin/sh
cd $(dirname "$1")
echo $(/bin/pwd)/$(basename "$1")
(Note: I added quotes around $1, but that shouldn't change the
behavior for /etc/passwd.)
Michael Henry
More information about the Ma-linux
mailing list