Re: [CentOS] Get only script name with shell script
Thanks for all reply and advice.I am glad to meet that people like help to other people. 2009/4/24 Stephen Harris : > On Fri, Apr 24, 2009 at 11:45:26AM -0700, Paul Heinlein wrote: >> $(basename $0) > > > Since you're using $() syntax, you can probably use the extended > shell variable expressions > ${0##*/} > and avoid running an external program :-) > > (works in ksh, bash, zsh but not original traditional sh) > > -- > > rgds > Stephen > ___ > CentOS mailing list > CentOS@centos.org > http://lists.centos.org/mailman/listinfo/centos > -- Iyi calismalar.Basarilar... Semih Gokalp Istanbul/Turkiye ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Get only script name with shell script
On Fri, Apr 24, 2009 at 11:45:26AM -0700, Paul Heinlein wrote: > $(basename $0) Since you're using $() syntax, you can probably use the extended shell variable expressions ${0##*/} and avoid running an external program :-) (works in ksh, bash, zsh but not original traditional sh) -- rgds Stephen ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Get only script name with shell script
On Fri, 24 Apr 2009, Semih Gokalp wrote: > Hi all, > > I wrote shell script and put it under the /usr/local/bin/ directory. > > I use echo $0 for get script name but it has printed > "/usr/local/bin/" but i want to only print > > How can i do this ? $(basename $0) -- Paul Heinlein <> heinl...@madboa.com <> http://www.madboa.com/ ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Get only script name with shell script
On Fri, Apr 24, 2009 at 09:35:00PM +0300, Semih Gokalp wrote: > Hi all, > > I wrote shell script and put it under the /usr/local/bin/ directory. > > I use echo $0 for get script name but it has printed > "/usr/local/bin/" but i want to only print I use: PROGRAM=$(basename $0) in all my scripts to tag the name of the currently executing script. John -- "I'm sorry but our engineers do not have phones." As stated by a Network Solutions Customer Service representative when asked to be put through to an engineer. "My other computer is your windows box." Ralf Hildebrandt trying to play sturgeon while it's under attack is apparently not fun. pgpyJi7pQwsFL.pgp Description: PGP signature ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Get only script name with shell script
Thanks Bob very thanks. 2009/4/24 Bob Beers : > On Fri, Apr 24, 2009 at 2:35 PM, Semih Gokalp wrote: >> Hi all, >> >> I wrote shell script and put it under the /usr/local/bin/ directory. >> >> I use echo $0 for get script name but it has printed >> "/usr/local/bin/" but i want to only print >> >> How can i do this ? >> > > man basename > ___ > CentOS mailing list > CentOS@centos.org > http://lists.centos.org/mailman/listinfo/centos > -- Iyi calismalar.Basarilar... Semih Gokalp Istanbul/Turkiye ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Get only script name with shell script
On Fri, 24 Apr 2009, Semih Gokalp wrote: > I wrote shell script and put it under the /usr/local/bin/ directory. > > I use echo $0 for get script name but it has printed > "/usr/local/bin/" but i want to only print > > How can i do this ? Instead of: echo $0 use: echo `basename $0` -Steve ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Get only script name with shell script
From: Semih Gokalp Sent: April 24, 2009 11:35 > > I use echo $0 for get script name but it has printed > "/usr/local/bin/" but i want to only print Try: `basename $0` HTH Regards, Hugh -- Hugh E Cruickshank, Forward Software, www.forward-software.com ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Get only script name with shell script
On Fri, 2009-04-24 at 21:35 +0300, Semih Gokalp wrote: > Hi all, > > I wrote shell script and put it under the /usr/local/bin/ directory. > > I use echo $0 for get script name but it has printed > "/usr/local/bin/" but i want to only print > > How can i do this ? Man "basename". This is used to strip leading path. > > Thanks all for help. > > -- Bill ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Get only script name with shell script
On Fri, Apr 24, 2009 at 1:35 PM, Semih Gokalp wrote: > Hi all, > > I wrote shell script and put it under the /usr/local/bin/ directory. > > I use echo $0 for get script name but it has printed > "/usr/local/bin/" but i want to only print > > How can i do this ? basename $0 ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Re: [CentOS] Get only script name with shell script
On Fri, Apr 24, 2009 at 2:35 PM, Semih Gokalp wrote: > Hi all, > > I wrote shell script and put it under the /usr/local/bin/ directory. > > I use echo $0 for get script name but it has printed > "/usr/local/bin/" but i want to only print > > How can i do this ? > man basename ___ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos