Saturday, March 30, 2013

Shell Meta characters For Linux


Shell Meta characters For Linux

Meta characters - These are special characters that are recognised by the shell.
 * - matches 0 or more characters.
     eg: ls *.c

? - matches any single character
    eg: ls ab?.c


[] - This will match any single character in the range.
     eg: ls tut[0-9].m
     This will find files such as tut0.m, tut9.m etc.,

> - Redirect standard output to a file.
    echo “hello world” > hello.txt

>> - Appends standard output to a file.
    eg: echo “Hello Again” >> hello.txt

< - Takes standard input from a file

| - This is pipe character. Sends the output of first command as input for the
second command.

mkdir – make directory
     usage: mkdir <dirname>
     eg: mkdir -p path/test/test1
     -p -> no error if existing, make parent directories as needed

cd - change directories
    Use cd to change directories. Type cd followed by the name of a directory to
access that directory.

mv - change the name of a directory
Type mv followed by the current name of a directory and the new name of
the directory.
    Ex: mv testdir newnamedir

cp - copy files and directories
usage: cp source destination
     cp -i myfile yourfile
     With the "-i" option, if the file "yourfile" exists, you will be prompted before it is
overwritten.

     cp -r srcdir destdir
     Copy all files from the directory "srcdir" to the directory "destdir" recursively.

rmdir - Remove an existing directory

rm - remove files or directories
Usage: rm -r name
     Removes directories and files within the directories recursively.

Shell Meta characters For Linux


No comments:

Post a Comment

Linux Tips and tricks,Online Linux Helpers