Many computer enthusiasts imitate the DIR environment scripts from Unix or Linux operating systems. However, many people start from other systems and use different commands and different types of interactions. For example, it is very likely that employees in your company are more accustomed to using the doscommand than a shell interpreter. Using a series of alias commands can slightly reduce this difference. For example, you can map the doscommand to the ls command of unix in the city: alias DIR = ls. However, if you have learned to use/w to represent the wide List format in dos, this ing will have no effect. Because unix Commands warn against the absence of the/w directory. Replace it with the following DIR script to map one type of Command Options to another type of environment, just like the one written earlier to change the input of the package. Code: 01 #! /Bin/sh02 03 # DIR. sh -- pretend that we are using the DOS dir command 04 # Use the dir command to display the content of the given file, this command Accepts standard dir option 05 06 function usage07 {08 cat <EOF> & 209 Usage: $ (basename $0) [DOS flags] directory or directories10 where: 11/D sort by columns12/H show help for this shell script13/N show long listing format with filenames on right14/OD sort by oldest to newest15/O-D sort by newest to oldest16/P pause after each screenful of in Formation17/Q show owner of the file18/S recursive listing19/W use wide listing format20 EOF21 exit 122} 23 24 postcmd = "" 25 flags = "" 26 27 while [$ #- gt 0] 28 do29 case $1 in30/D) flags = "$ flags-x"; 31/H) usage; 32/[NQW]) flags = "$ flags-l"; # Regular Expression 33/OD) flags = "$ flags-rt"; 34/O-D) flags = "$ flags-t"; 35/P) postcmd = "more"; 36/S) flags = "$ flags-s"; 37 *) break; # unknown option: it may be a file descriptor, so exit loop 38 Esac39 shift40 done41 42 if [! -Z "$ postcmd"]; then43 ls $ flags "$ @" | $ post000044 else45 ls $ flags "$ @" 46 fi47 48 exit 0 how to run the script: this script highlights the truth: the case statement in the shell script is actually a regular expression, which is very useful. You can see that the/N,/Q, And/W options in dos are mapped to the-l option of the ls command in unix. Theoretically, users should be granted the syntax and options in the unix environment, but that is not necessarily necessary. Of course, before calling this script, you can view the help options in the script to understand all the ing options. Run the Script: Name the script DIR. sh. When you type a typical doscommand option on the command line, a meaningful output is generated, instead of the previous error message: command not found running result: 01 $ DIR/OD/S/Volumes/110 GB/02 total 6068003 0 WEBSITES 64 Desktop DB04 0 Writing 0 Temporary Items05 0 Microsoft Office X 29648 Norton FS Volume 206 0 Documents 29648 Norton FS volume07 0 TheVolumeSettingsFolder 0 iTunes Library08 0 Trash 8 Norton FS Index09 816 Norton FS Data 0 Desktop Folder10 496 TB Op DF 0 Desktop Picture Archive the directory is sorted from the oldest to the latest, and the file size is displayed.