LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-05-2012, 07:12 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 539

Rep: Reputation: 33
[bash script] What does this mean? -- FILE=${LIST##*/}


I read a script wrote from one of my former colleague and it looks as follow:

Code:
...
    for LIST in $(find $OUTPUTPATH -type f); do
      FILE=${LIST##*/}
...
I wonder what does here the LIST##* mean.

Someone knows?
 
Old 03-05-2012, 07:21 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Return a copy of the string, having deleted everything up to the last slash. Whilst it's "clever" doing that in pure bash, i'd personally have used the "basename" command, which is so much clearer.
Quote:
Substring Removal

${string#substring}
Deletes shortest match of $substring from front of $string.

${string##substring}
Deletes longest match of $substring from front of $string.

stringZ=abcABC123ABCabc
# |----| shortest
# |----------| longest

echo ${stringZ#a*C} # 123ABCabc
# Strip out shortest match between 'a' and 'C'.

echo ${stringZ##a*C} # abc
# Strip out longest match between 'a' and 'C'.



# You can parameterize the substrings.

X='a*C'

echo ${stringZ#$X} # 123ABCabc
echo ${stringZ##$X} # abc
# As above.
http://tldp.org/LDP/abs/html/string-manipulation.html

Last edited by acid_kewpie; 03-05-2012 at 07:22 AM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need bash script to list files, drop extension and dump to file talwar_ Programming 10 06-03-2011 09:18 AM
Bash script to fgrep a large file. With list as source for searching. the_file Linux - Newbie 14 01-24-2011 03:42 PM
[SOLVED] Partial list with ls-l in bash script run in cron but full list run from command line redgshost Linux - General 29 01-16-2011 12:14 PM
Bash script: how do I select second-to-last argument in a list Robert S Linux - Software 2 11-23-2007 03:06 PM
Bash script - mailing list haze Programming 3 05-05-2005 12:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:39 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
Open Source Consulting | Domain Registration