1. basename
is the name left after the directory is removed .
example:shell>temp=/home/temp/1.test
shell>base= ' basename $temp '
Shell>echo $base
The result is: 1.test
2. dirname
is to fetch directory
example:shell>temp=/home/temp/1.test
shell>dir= ' dirname $temp '
Shell>echo $dir
The result is:/home/temp
another way to implement:
${var##*/} is to remove the last/and left contents of the Var variable
${var%/*} is the last/and the right of the variable var is removed
3.Read
#!/bin/bash
echo-n "Enter Your Name:"//Parameter-n is not wrapped, echo defaults to line wrapping
read name//input from keyboard
echo "Hello $name, Welcome to my program"//Display information
Exit 0//Quit Shell program.
//********************************
because the Read command provides the-p parameter, it allows you to specify a prompt directly on the read command line.
so the script above can be simply written in the following script:
#!/bin/bash
read-p "Enter Your Name:" Name
echo "Hello $name, Welcome to my program"
Exit 0
basename dirname read in the shell