LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need information about wild cards (https://www.linuxquestions.org/questions/linux-newbie-8/need-information-about-wild-cards-665839/)

shridhar005 08-27-2008 01:31 PM

Need information about wild cards
 
Hello gentlemen
I need all information regarding wild characters used in Linux. Including those used in shell scripting , used along with text processing commands .
:scratch::scratch::scratch::scratch::scratch:

matthewg42 08-27-2008 01:41 PM

There are generally two types of pattern used in the shell and the coreutils:
  1. glob patterns - "*" means any combination of characters, "?" means any single character. This is what gets expanded when you do a command like:
    Code:

    ls -l *.txt
    The critical thing to realise if you come from a DOS background, and maybe even if you don't, is that the shell expands the glob pattern to all matching files before passing the list of argument to the command. In the example above, ls does not generally see the * - the shell expands this before it invokes ls. In the case when the pattern does not match any files (i.e. there are no files ending in ".txt"), the "*.txt" will be passed as a litereal string, but ls is not expected to treat it as a pattern - it will treat it as a literal string and try to list a file called "*.txt", which presumably will not be found.
  2. Regular expressions. Many core utilities like grep understand regular expressions (REs). RE's are a mini language for describing string patterns. There are a few variants of regular expressions, including standard REs, extended REs, Perl compatible REs. These arose as the original REs got extended to add new functionality. Read the regex manual page, and do some tutorials. Once you learn how to use REs, you will wonder how you ever coped without them.


All times are GMT -5. The time now is 01:55 AM.