Re: OT: bash question

2014-03-06 Thread Todor Petkov
On 05/03/2014 10:13 PM, Mike Wright wrote: Hi all, I need to extract the name of a parent directory, not the whole path. Combinations of dirname and cut didn't get me anywhere. Given this: (the ... indicates that I don't know the dir depth) /.../mydir/my.file How would I extract this: /...

Re: OT: bash question

2014-03-05 Thread Jon Ingason
2014-03-05 21:13, Mike Wright skrev: > Hi all, > > I need to extract the name of a parent directory, not the whole path. > > Combinations of dirname and cut didn't get me anywhere. > > Given this: (the ... indicates that I don't know the dir depth) > > /.../mydir/my.file > > How would I extra

Re: OT: bash question

2014-03-05 Thread Kevin Martin
On 03/05/2014 02:29 PM, Joe Benson wrote: > dirname /PATH/PATH/PATH/filename.txt | awk -F"/" '{print $NF}' should do > it. > > > On Wed, Mar 5, 2014 at 1:13 PM, Mike Wright > wrote: > > Hi all, > > I need to extract the name of a parent directory

Re: OT: bash question

2014-03-05 Thread Joe Benson
dirname /PATH/PATH/PATH/filename.txt | awk -F"/" '{print $NF}' should do it. On Wed, Mar 5, 2014 at 1:13 PM, Mike Wright wrote: > Hi all, > > I need to extract the name of a parent directory, not the whole path. > > Combinations of dirname and cut didn't get me anywhere. > > Given this: (th

Re: OT: bash question

2014-03-05 Thread CS DBA
On 03/05/2014 01:13 PM, Mike Wright wrote: Hi all, I need to extract the name of a parent directory, not the whole path. Combinations of dirname and cut didn't get me anywhere. Given this: (the ... indicates that I don't know the dir depth) /.../mydir/my.file How would I extract this: /..

OT: bash question

2014-03-05 Thread Mike Wright
Hi all, I need to extract the name of a parent directory, not the whole path. Combinations of dirname and cut didn't get me anywhere. Given this: (the ... indicates that I don't know the dir depth) /.../mydir/my.file How would I extract this: /.../mydir/my.file ^ TIA to all takers

Re: OT: bash question

2011-01-31 Thread Bruno Wolff III
On Mon, Jan 31, 2011 at 12:55:36 -0800, Mike Wright wrote: > > I'm trying to create a self-contained app in that it is both a data > repository and also the location of its binary (BIN/runme, DATA/) so > that the application could be installed anywhere in user space and still > be able to fi

Re: OT: bash question

2011-01-31 Thread Frantisek Hanzlik
Alan J. Gagne wrote: >> My mistake. I forgot to say that the file was invoked from a link. >> Your proposed solution shows the link's location. I have to discover >> the target of the link. > > echo `ls -la $0` This will point only to first target. "readlink" has switches for recursive resolv.

Re: OT: bash question

2011-01-31 Thread Mike Wright
Frantisek Hanzlik wrote: > Mike Wright wrote: >> Alan J. Gagne wrote: >>> You could try echo $0 from inside you script. >> Thanks Alan. >> >> My mistake. I forgot to say that the file was invoked from a link. >> Your proposed solution shows the link's location. I have to discover >> the target

OT: bash question

2011-01-31 Thread Alan J. Gagne
> My mistake. I forgot to say that the file was invoked from a link. > Your proposed solution shows the link's location. I have to discover > the target of the link. echo `ls -la $0` -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin

Re: OT: bash question

2011-01-31 Thread Frantisek Hanzlik
Mike Wright wrote: > Alan J. Gagne wrote: >> You could try echo $0 from inside you script. > > Thanks Alan. > > My mistake. I forgot to say that the file was invoked from a link. > Your proposed solution shows the link's location. I have to discover > the target of the link. > > Ever onward!

Re: OT: bash question

2011-01-31 Thread Mike Wright
Alan J. Gagne wrote: > You could try echo $0 from inside you script. Thanks Alan. My mistake. I forgot to say that the file was invoked from a link. Your proposed solution shows the link's location. I have to discover the target of the link. Ever onward! -- users mailing list users@lists.fe

Re: OT: bash question

2011-01-31 Thread suvayu ali
On Mon, Jan 31, 2011 at 12:32 PM, Mike Wright wrote: > s there a bash command that tells an executing script what *its* path > is?  Not the path where the user is but where the script is. $ cat ./test.sh #!/bin/bash echo $0 is the script echo `dirname $0` is the script location exit $? HTH --

OT: bash question

2011-01-31 Thread Alan J. Gagne
You could try echo $0 from inside you script. -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

Re: OT: bash question

2011-01-31 Thread Mike Wright
Bruno Wolff III wrote: > On Mon, Jan 31, 2011 at 12:32:24 -0800, > Mike Wright wrote: >> Hi all, >> >> Not sure where to find the answer to this question. Google wasn't >> helpful. The users on this list are a great repository of knowledge so >> I thought to try here. >> >> Is there a bash c

Re: OT: bash question

2011-01-31 Thread Bruno Wolff III
On Mon, Jan 31, 2011 at 12:32:24 -0800, Mike Wright wrote: > Hi all, > > Not sure where to find the answer to this question. Google wasn't > helpful. The users on this list are a great repository of knowledge so > I thought to try here. > > Is there a bash command that tells an executing s

OT: bash question

2011-01-31 Thread Mike Wright
Hi all, Not sure where to find the answer to this question. Google wasn't helpful. The users on this list are a great repository of knowledge so I thought to try here. Is there a bash command that tells an executing script what *its* path is? Not the path where the user is but where the scr