Sponsored Content
Full Discussion: what these statements means
Top Forums UNIX for Dummies Questions & Answers what these statements means Post 302159053 by frank_rizzo on Thursday 17th of January 2008 01:20:50 AM
Old 01-17-2008
Please try to search for the solution first. The man command is your best friend! If your not using bash it might not be in the man page but there plenty of examples on the net.

This is directly taken from the bash man page.


Code:
       ${parameter#word}
       ${parameter##word}
              The  word  is  expanded to produce a pattern just as in pathname expansion.  If the
              pattern matches the beginning of the value of parameter, then  the  result  of  the
              expansion  is  the  expanded  value of parameter with the shortest matching pattern
              (the ‘‘#’’ case) or the longest matching pattern (the  ‘‘##’’  case)  deleted.   If
              parameter  is  @  or *, the pattern removal operation is applied to each positional
              parameter in turn, and the expansion is the resultant list.   If  parameter  is  an
              array variable subscripted with @ or *, the pattern removal operation is applied to
              each member of the array in turn, and the expansion is the resultant list.

       ${parameter%word}
       ${parameter%%word}
              The word is expanded to produce a pattern just as in pathname  expansion.   If  the
              pattern  matches  a  trailing  portion of the expanded value of parameter, then the
              result of the expansion is the expanded value of parameter with the shortest match‐
              ing  pattern  (the  ‘‘%’’  case)  or the longest matching pattern (the ‘‘%%’’ case)
              deleted.  If parameter is @ or *, the pattern removal operation is applied to  each
              positional  parameter in turn, and the expansion is the resultant list.  If parame‐
              ter is an array variable subscripted with @ or *, the pattern removal operation  is
              applied  to  each  member  of the array in turn, and the expansion is the resultant
              list.

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

$? means?

Hi All, Can you please explain wats the meaning of this $? in unix Thanks (2 Replies)
Discussion started by: mathur
2 Replies

2. Shell Programming and Scripting

$$ means?

hey, what's $$varname in a script? I used to see $varname only. search on google didn't help. thanks. (4 Replies)
Discussion started by: patiobarbecue
4 Replies

3. UNIX for Dummies Questions & Answers

Can you tell me what this means?

Can you please tell me what this means? use grep to find from the file myfile.txt all lines containing the sequence tt but not more 2 ts? I have no idea. (2 Replies)
Discussion started by: rushhour
2 Replies

4. UNIX for Advanced & Expert Users

what does $#,$* means

:) Hi, In some script i got these regular expression like , n=$# and for i in $* can anybody let me know, what does it means (5 Replies)
Discussion started by: deb.simply
5 Replies

5. UNIX for Dummies Questions & Answers

What means %U

I can not find out what the %U means in the following command: ooffice -calc %U (2 Replies)
Discussion started by: borobudur
2 Replies

6. Shell Programming and Scripting

!! what is this means

I have a script like select * from table !! what those exclamation marks mean (4 Replies)
Discussion started by: vasuarjula
4 Replies

7. Shell Programming and Scripting

What does . means?

Hi, I have seen in some ksh script, that we are executing shell scripts inside other shell script as . variable.sh What is . here? Their is space between . and variabloe. And why we are not executing it like ./variable.sh? I know that . signifies current directory , but what its... (2 Replies)
Discussion started by: jatanig
2 Replies

8. Shell Programming and Scripting

$? and $# means

what exactly $? and $# means ? (1 Reply)
Discussion started by: mail2sant
1 Replies

9. Programming

What does it means?

#define abc '\xE8' (7 Replies)
Discussion started by: kamlesh33
7 Replies
GLOB(7) 					       BSD Miscellaneous Information Manual						   GLOB(7)

NAME
glob -- shell-style pattern matching DESCRIPTION
Globbing characters (wildcards) are special characters used to perform pattern matching of pathnames and command arguments in the csh(1), ksh(1), and sh(1) shells as well as the C library functions fnmatch(3) and glob(3). A glob pattern is a word containing one or more unquoted '?' or '*' characters, or ``[..]'' sequences. Globs should not be confused with the more powerful regular expressions used by programs such as grep(1). While there is some overlap in the special characters used in regular expressions and globs, their meaning is different. The pattern elements have the following meaning: ? Matches any single character. * Matches any sequence of zero or more characters. [..] Matches any of the characters inside the brackets. Ranges of characters can be specified by separating two characters by a '-' (e.g. ``[a0-9]'' matches the letter 'a' or any digit). In order to represent itself, a '-' must either be quoted or the first or last character in the character list. Similarly, a ']' must be quoted or the first character in the list if it is to represent itself instead of the end of the list. Also, a '!' appearing at the start of the list has special meaning (see below), so to represent itself it must be quoted or appear later in the list. Within a bracket expression, the name of a character class enclosed in '[:' and ':]' stands for the list of all characters belonging to that class. Supported character classes: alnum cntrl lower space alpha digit print upper blank graph punct xdigit These match characters using the macros specified in ctype(3). A character class may not be used as an endpoint of a range. [!..] Like [..], except it matches any character not inside the brackets. Matches the character following it verbatim. This is useful to quote the special characters '?', '*', '[', and '' such that they lose their special meaning. For example, the pattern ``\*[x]?'' matches the string ``*[x]?''. Note that when matching a pathname, the path separator '/', is not matched by a '?', or '*', character or by a ``[..]'' sequence. Thus, /usr/*/*/X11 would match /usr/X11R6/lib/X11 and /usr/X11R6/include/X11 while /usr/*/X11 would not match either. Likewise, /usr/*/bin would match /usr/local/bin but not /usr/bin. SEE ALSO
fnmatch(3), glob(3), re_format(7) HISTORY
In early versions of UNIX, the shell did not do pattern expansion itself. A dedicated program, /etc/glob, was used to perform the expansion and pass the results to a command. In Version 7 AT&T UNIX, with the introduction of the Bourne shell, this functionality was incorporated into the shell itself. BSD
November 30, 2010 BSD
All times are GMT -4. The time now is 03:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy