LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-18-2014, 11:50 AM   #1
anandg111
Member
 
Registered: Jan 2012
Posts: 56

Rep: Reputation: Disabled
${0##*/}


base=${0##*/}

can someone please explain this ?

Last edited by anandg111; 02-18-2014 at 12:05 PM.
 
Old 02-18-2014, 12:00 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,256

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Where did you get it from? To be honest, unless called in a script it is quite meaningless.

You may also like to read http://www.catb.org/~esr/faqs/smart-questions.html, as your current effort leaves little to be desired.
 
Old 02-18-2014, 12:04 PM   #3
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,970
Blog Entries: 1

Rep: Reputation: 208Reputation: 208Reputation: 208
Same effect as

Code:
$(basename $0)
You're trimming everything to the left using '/' as a delimiter.

--C
 
Old 02-18-2014, 05:43 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
anandg111, see the bash(1) manpages, under the "Parameter Expansion" section. There are a number of interesting features here, none of which require firing off a child process.

Some of my favorites:
Code:
[texas] ~> _line='Stay warm'

[texas] ~> echo "The length of \$_line is ${#_line}"
The length of $_line is 9

[texas] ~> echo "The first six characters from \$_line are ${_line:0:6}"
The first six characters from $_line are Stay w

[texas] ~> echo "Replacing (warm) with (happy) gives us: ${_line/warm/happy}"
Replacing (warm) with (happy) gives us: Stay happy

[texas] ~> echo "Greedily stripping prefix up to (a) results in: ${_line##*a}"
Greedily stripping prefix up to (a) results in: rm

[texas] ~> echo "Greedily stripping suffix up to (a) results in: ${_line%%a*}"
Greedily stripping suffix up to (a) results in: St
Anyway - read the manpages.
 
Old 02-19-2014, 06:19 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
A really good page on Parameter Expansions & related tricks http://wiki.bash-hackers.org/syntax/pe
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off




All times are GMT -5. The time now is 10:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration