Javatpoint Logo
Javatpoint Logo

Displaying Shell Expansion

When a command is entered in the command line, it expands into its output which is displayed.

This is called expansion.

The command you're typing will be printed with the help of echo command on the terminal. This command will be useful when you want to check what your command is doing in the shell.

CommandFunction
set -xUsed to enable shell expansion.
set +xUsed to disable shell expansion.

set -x

The 'set -x' command enables shell command display.

Syntax:

Example:

Linux Shell Expansion Displaying1

Look at the above snapshot, 'set -x' displays shell expansion in the terminal. You can see what the shell is doing with the given command. With command "echo $USER" shell expansion shows that $USER is converted to 'sssit'.

With command "echo \$USER" shell expansion shows that due to special character backslash (\) $USER is not converted to 'sssit'.

set +x

The 'set +x' command disables shell command display.

Syntax:

Example:

Linux Shell Expansion Displaying2

Look at the above snapshot, shell expansion is disabled and hence, output is directly printed in the terminal.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA