String Substitution
HI Guys,
I get File Names in as I or U as Suffix at the End of a File Name and I wanted to retrieve that I or U from the File name and run the processes acordingly. I got the solution to this as well. For Ex: a="US_SALES_08_2008_I" b=`echo ${a##*_}` the variable b displays I in this case. But i wanted to know the role that # and * plays in the command. Can i get information on any site from whether i can learn the shortcuts and more information on the linux commands as well. Thanks in advance, Swapna |
This is an example of parameter substitution. The syntax here is
Code:
${var##Pattern} In a pattern the asterisk means any sequence of characters (zero included). In your example all the characters before the last underscore and the underscore itself are removed, leaving I or U as required. You can find a detailed description of parameter substitution, along with a lot of examples, in the Advanced Bash Scripting Guide, here. A pdf version of this document is also available. |
All times are GMT -5. The time now is 07:00 PM. |