tailieunhanh - Mastering unix shell scripting p7

Liệt kê 9,7 simple_SQL_query chức năng danh sách. Các chức năng được hiển thị trong Ví dụ 9,7 có thể được rút ngắn hơn nữa, nếu bạn đã đăng nhập vào hệ thống như người sử dụng oracle hoặc thực hiện một kịch bản như là người sử dụng oracle. | 398 Chapter 15 Using FILENAME as input MUST USE DOUBLE QUOTES AROUND PATTERN - PATTERN cat FILENAME sed s PATTERN tput smso PATTERN tput rmso g OUTPUT_FILE else Input is from standard input. MUST USE DOUBLE QUOTES AROUND PATTERN - PATTERN sed s PATTERN tput smso PATTERN tput rmso g OUTPUT_FILE Check to see if the pattern was in the standard input grep PATTERN OUTOUT_FILE dev null 2 1 if -ne 0 then echo nSORRY The string c tput smso echo PATTERN c tput rmso echo was not found in standard input c echo n . n exit 3 fi fi Check the operating system on AIX and HP-UX we need to use the pg or page command. The more command does not work to highlight the text it will show only the characters that make up the escape sequence. All other operating systems use the more command. case uname in aix hp-ux This is a fancy pg command. It acts similarly to the more command but instead of showing the percentage displayed it shows the page number of the file usr bin cat OUTPUT_FILE usr bin pg -csn -p Page d Listing shell script. continued hgrep Highlighted grep Script 399 usr bin cat OUTPUT_FILE usr bin more esac rm -f OUTPUT_FILE End of Script Cleanup Listing shell script. continued In the shell script in Listing we first check for the correct number of commandline arguments either one or two arguments are valid. Otherwise the script usage message is displayed and the script will exit with a return code 1. If we have the correct number of arguments then we assign the arguments to variables. If we have two command-line arguments then an input file is specified in 2 at least it is supposed to be a file. We need to do some sanity checking on this second command-line argument by first checking to see that the file exists as a regular file. We do not want to do anything with the file if it is a block or character special file a directory or any other nonregular file. Next we make sure that the file is not empty. Then we ensure that the script can

TỪ KHÓA LIÊN QUAN