readex.ksh

来自「Solaris环境下Shell编程编程」· KSH 代码 · 共 35 行

KSH
35
字号
#!/bin/ksh# Script name: readex.ksh###### Step 1 - Copy /etc/hostscp /etc/hosts /tmp/hosts2##### Step 2 - Strip out comment linesgrep -v '^#' /tmp/hosts2 > /tmp/hosts3  ##### Step 3 - fd 3 is an input file /tmp/hosts3exec 3< /tmp/hosts3##### Step 4 - fd 4 is output file /tmp/hostsfinalexec 4> /tmp/hostsfinal#####  The following 4 statements accomplish STEP 5read -u3 addr1 name1 alias	# read from fd 3 read -u3 addr2 name2 alias	# read from fd 3print -u4 $name1 $addr1		# write to fd 4 (do not write aliases)print -u4 $name2 $addr2		# write to fd 4 (do not write aliases) #####  END OF STEP 5 statementsexec 3<&-			# Step 6 - close fd 3exec 4<&-			# Step 7 - close fd 4

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?