A simple shell written by yourself

xiaoxiao2021-03-06  23

#! / bin / sh #################################################################################################################################################################################################################################################################################################### ########################### Ganmao: 2005-3-22 ## A simple shell menu, for Convenient to use #### usage (): ## menu.sh ############################################################################################################################################################################################################################################################################ #############################################################

# Read environment variables. .Profile

# --------- Function Definition ----------------

# Intermittent function, control display time, have parameters, set intermittent time and display symbol # function use: JDT parameter 1 parameter 2 # Parameters 1: Set intermittent time parameter 2: Set the display symbol JDT () {DELAY = $ 1D_SIGN = $ 2NUMBER = 0echowhile (TEST $ Number -LT $ DELAY) Do Echo -n $ D_SIGN SLEP 1 Number = `EXPR $ Number 1`done}

# 菜 list function list () {clear echo "Your current login user is:" `WHOAMI` Echo" your current path is: "` PWD` Echo echo "************ *** Main menu *************** "echo" (1) ------------------ list the contents of the directory "Echo" (2) ------------------- Change the current directory "echo" -------------------------------------------------------------------------------------------------------------------- ------- Modify the file "echo" (4) ---------------------- Delete file "######### ########################################## In the following menu, fill in the corresponding menu Description # Format is: echo "[menu label] --------- [menu description]" ##################### # Add custom menu content ############

################################################################################################ -------------- Exit menu "Echo echo -n" Please enter the menu number: "}

# 程序 程序 执行函 函,: Parameter Parameter Parameters ENEC_SH () {Choice = $ 1 Case $ Choice in 1) Echo `PWD`"> "ls -l ls -l ;; 2) Echo Enter Target Directory Read DIR CD $ DIR ;; 3) Echo Enter File Name Read File Vi $ File ;; 4) Echo Enter File Name READ FILE RM $ FILE ;; ################### #################################################################### The number must be the same as the description # format: # [menu label]) program execute command # ;; ############################################################################################################################################################################################################################################################################ ########################################################################################################################################################################################################################################################################################################### # *) Echo echo "Enter an error, please enter the correct menu number" ;; ESAC}

# ----------- Main Program ------------- DelayTime = 2 # Settings When the system is displayed, the idle time D_SIGN = "->" is set when the system is idle symbol

Until List Read Choice Test $ Choice = "Q" -O $ Choice = "Q" Do EXEC_SH $ Choice JDT $ DelayTime $ D_SIGNDOONE

echo "You have quit the menu!"

转载请注明原文地址:https://www.9cbs.com/read-43339.html

New Post(0)