What are shell metacharacters like \ and >?

What are shell metacharacters like \ and >?
LVL 1
naseeamAsked:
Who is Participating?
 
avizitCommented:
the
'\' 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

http://www.bo.infn.it/alice/alice-doc/mll-doc/linux/vi-ex/node56.html
0
 
ezatonCommented:
Add backslash before the characters to use them, if that is what you mean. Example:
$ ls | grep file
\file

$ rm \\file

Same goes for other special characters.
0
 
TintinCommented:
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.
0
 
hernst42Commented:
from man bash:
DEFINITION
       metacharacter
              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
       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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.