readex.sh

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

SH
35
字号
#!/bin/sh# Script name: readex.sh##### 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 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 <& 3 addr1 name1 alias	# Read from fd 3read <& 3 addr2 name2 alias	# Read from fd 3echo $name1 $addr1 >& 4		# Write to fd 4 (do not write aliases)echo $name2 $addr2 >& 4		# 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 + -
显示快捷键?