LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 08:12 AM   #1
thomas2004ch
Member
 
Registered: Aug 2009
Posts: 537

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, 08:21 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982Reputation: 1982
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 08:22 AM.
 
  


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



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 10:18 AM
Bash script to fgrep a large file. With list as source for searching. the_file Linux - Newbie 14 01-24-2011 04: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 01:14 PM
Bash script: how do I select second-to-last argument in a list Robert S Linux - Software 2 11-23-2007 04:06 PM
Bash script - mailing list haze Programming 3 05-05-2005 01:03 AM

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

All times are GMT -5. The time now is 06:28 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