Presentation is loading. Please wait.

Presentation is loading. Please wait.

Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces.

Similar presentations


Presentation on theme: "Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces."— Presentation transcript:

1 Shell Advanced Features

2 Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces. The shell capabilities provide a configurable environment allowing the users to modify commands and prompts. ♦ Topics ► Shell Substitution Capabilities ► Setting Shell Variables ► Quoting Characters ► File Name Generationss

3 Shell Advanced Features Shell Substitution Capabilities ♦ Substitution capabilities are used to speed up command line typing and execution. ♦ The shell substitutions are of three types: ► Variable Substitution ► Command substitution ► Tilde Substitution Contd…

4 Shell Advanced Features Shell Substitution Capabilities ♦ Variable Substitution ► Variable substitution is assigning the absolute path of a file or directory to any variable. This allows the user to access the directory or file from anywhere in the file hierarchy. Syntax: =$ Example: myfile=$HOME/file1 Contd…

5 Shell Advanced Features Shell Substitution Capabilities ♦ Command substitution ► Command substitution is the mechanism used to replace a command with its output, within the same command line. Syntax: =$(command) Example: mydir=$ (pwd) Contd…

6 Shell Advanced Features ♦ Tilde Substitution A tilde is replaced for the quick reference of home directory. Syntax: ~ Example: ls ~ Shell Substitution Capabilities

7 Shell Advanced Features ♦ The new variable can be created and assigned to an existing environmental variable such as path. ♦ The new value replaces the old value in the environment and the same can be displayed by using the display value commands. Syntax = Example myfile_name=/root/file1 Contd… Setting Shell Variables

8 Shell Advanced Features Setting Shell Variables ♦ Displaying variable values ► The variables can be displayed by using $. ► It can be local variable (assigned by the user) or environmental variable (default variable). ► All setting variables can be displayed by using the command set.

9 Shell Advanced Features Quoting Characters ♦ There are some characters in the Unix system and each has the meaning for the shell and is called as special characters. The special characters are: ► - ► $ ► # ► * ► ♦ Quoting removes the special meaning of the above characters. The quoting characters are: ► \ Backslash ► ‘ ’ Single quotes ► “ ” Double quotes Contd…

10 Shell Advanced Features Contd… ♦ Backslash ( \ ) Backslash removes the special meaning of the character immediately following the backslash. Quoting Characters

11 Shell Advanced Features ♦ Single quotes ( ‘ ’) The single quote is used to preserve the literal value of special character enclosed within the quotes. Contd… Quoting Characters

12 Shell Advanced Features Quoting Characters ♦ Double quotes ( “ ” ) Double quotes removes the special meaning of all the characters except \, $ (variable name), $ (command).

13 Shell Advanced Features ♦ The file name generation has the timesaving feature for typing the filenames. This feature is called file name generation or filename expansion. ► Advantages of file name generation File name generating characters are interpreted by the shell. The command operates on the generated file names. The shell will generate file names that satisfy the requested pattern. File name generation is done before the command is executed. ♦ The special characters that are interpreted by the shell for file name generation are: ? Matches any single character except a leading dot * Matches zero or more characters except a leading dot Contd… File Name Generation

14 Shell Advanced Features File Name Generation ♦ Usage of the special character ‘?’ Contd…

15 Shell Advanced Features File Name Generation ♦ Usage of the special character ‘*’

16 Shell Advanced Features Lab Exercise ♦ Give one example on usage of single quotes command with the variable substitution ♦ Display the files which has 9 characters and with the extension.jpg


Download ppt "Shell Advanced Features. Module 8 Shell Advanced Features ♦ Introduction In Linux systems, the shells are often referred to as command line interfaces."

Similar presentations


Ads by Google