Back Tics
Linux Commands - Shells

Back Tics
Back tics are used with external commands to execute a command separately from the script and then be used by the script.  In this example the text string inside back tics is executed to create the variable.

Lesson 3 | Lesson 5

 

This script lists the name of the individual that is logged in.
sysname.sh

#!/bin/sh
SYSNAME=`egrep "^${USER}:" /etc/passwd | cut -d: -f5`
echo $SYSNAME


The system name for the user is grabbed by looking at the start of the line "^" for in /etc/passwd and then cut is used to cut out the fifth field.  Echo is used to express the system name which has become a variable, $SYSNAME.

knowledge Increase Your Knowledge About the cut Command

back tics - use in a statement where you want to substitute the command inside the back tics

forward tics - use in a statement where you do not want character or command substitution

double quotes - use in statement where you want to use character or command substitution

 

 


Copyright CyberMontana Inc. and BeginLinux.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874