What are shell metacharacters like \ and >?

Posted on 2007-07-23
Last Modified: 2008-01-09
What are shell metacharacters like \ and >?
Question by:naseeam
    LVL 7

    Assisted Solution

    Add backslash before the characters to use them, if that is what you mean. Example:
    $ ls | grep file

    $ rm \\file

    Same goes for other special characters.
    LVL 11

    Accepted Solution

    '\' metacharacter gives special meaning to the next character
    for example  a  "." ( dot) in a regular expression can mean any character but when preceded by a \ it means a literal dot .

    >  redirects the standard output to a file .. say if you had a c program named test which had printfs
    then typing

    test > outfile
    would print the output to the outfile instead of  the console

    more metacharacters here
    LVL 48

    Assisted Solution

    1.  The backslash means that the next character should be used literally if it is a metacharacter.

    2.  > is for redirection to a file

    3.  ? is used by the shell to match a single character (similar to . in regex).  Remember that shell globs use some different characters to regexes for matching characters.
    LVL 48

    Assisted Solution

    from man bash:
                  A character that, when unquoted, separates words.  One of the following:
                  |  & ; ( ) < > space tab
           control operator
                  A token that performs a control function.  It is one of the following symbols:
                  || & && ; ;; ( ) | <newline>

           Quoting is used to remove the special meaning of certain characters or words to the shell.  Quoting can be used  to  disable  special  treatment  for special characters, to prevent reserved words from being recognized as such, and to prevent parameter expansion.

           Each of the metacharacters listed above under DEFINITIONS has special meaning to the shell and must be quoted if it is to represent itself.

           When  the command history expansion facilities are being used, the history expansion character, usually !, must be quoted to prevent history expansion.

           There are three quoting mechanisms: the escape character, single quotes, and double quotes.

    So the \ itself is no metacharacter for the shell, its just a quoting mechanism.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    This tutorial is posted by Aaron Wojnowski, administrator at  To view more iPhone tutorials, visit This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
    Recently, an awarded photographer, Selina De Maeyer (, completed a photo shoot of a beautiful event ( in An…
    Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
    The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now