关于从一个文件中读取之后如何返回到std input

#1/bin/bash -e
awk '#lokup -- reads local glossary file and prompts user for query
#0
BEGIN { FS = "\t"; OFS = "\t"
        #prompt user
        printf("Enter a glossary term:")

}
#1 read local file named glossary
FILENAME == "glossary"{
#oad each glossary entry into an arrray
        entry[$1] = $2
        next
}
#2 scan for command to exit program
$0 ~ /^(quit|[qQ]|exit|[Xx])$/ {exit}
#3 process any non-empty line
$0 != "" {
        if ($0 in entry) {
                #it is there, print definition
                print entry[$0]
        }else
                print $0 "not found"
#4 prompt user again for another term

printf("Enter another glossary term (q to quit):")

}' glossary -
通过在脚本的末尾加上文件名 - (glossary -),但是在ubuntu15.04 上测试不需要glossary  - ,其结果也是一样的。





你可能感兴趣的:(关于从一个文件中读取之后如何返回到std input)