LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shell scripting (https://www.linuxquestions.org/questions/linux-newbie-8/shell-scripting-4175535294/)

jamrodh singh 02-27-2015 11:33 AM

shell scripting
 
can some1 please tell me ....i am writing script to display type of file....and i m not able to get what "filename##*\." means?....please be brief in your explanation..thank you
the program is like:
for filename in$(ls)
do
ext=${filename##*\.}
case '$ext' in

suicidaleggroll 02-27-2015 11:51 AM

Need some context...

edit: thanks for the edit, looks like rknichols answered it.

rknichols 02-27-2015 12:56 PM

${filename##*\.} is the value of $filename with all leading characters up to and including the last "." character deleted. (The backslash escape on the "." is superfluous.)

${varname#*.} drops all leading characters up through the first "." (shortest string that matches "*.") The double "##" looks for the longest match.

It's all in the bash manpage under "Parameter Expansion".


All times are GMT -5. The time now is 07:18 PM.