awk study(2)
来源:互联网 发布:spss软件怎么安装 编辑:程序博客网 时间:2024/05/16 13:00
You can also run awk without any input files, if you type the follow command line
awk 'program'awk appies program to the standard input, which usually means whatever you type on the terminal, this continues until you indicate end-of-file by typing Ctrl+d(on the other operating systems, end-of-file charaters may be different).
As an example, the following program prints a friendly piece advice,to keep you from worring about the complexities of computer programming.
$awk "BEGIN {print /"Don't Panic/"}"This program doesn't read any input file. The character '/'before each of the inner double quote is necessary because of the shell's quoting rules---in particular it mixes both single quotes and double quotes.
| Don't Panic
The next simple awk program emulates the cat utility,it copies whatever you type on the keyboard to its standard output.
$ awk '{ print }'
Now is the time for all good men
-| Now is the time for all good men
to come to the aid of their country.
-| to come to the aid of their country.
Four score and seven years ago, ...
-| Four score and seven years ago, ...
What, me worry?
-| What, me worry?
Ctrl-d
1.1.3 Running long programs
Sometimes your awk programs can be very long,it is more convenient to put the programs into a separate file, in order to tell awk to use that file for its program, you type :
$awk -f source-file input-file1 input-file2
The -f instruct the awk utility to get the program from the file source-file, any file name can be used for the source-file.For example, you could put the program :
BEGIN {print "Don't Panic !"}
into a file advice , Then this command :
$awk -f advice
does the same thing as this one:
$awk "BEGIN {print /"Don't Panic/"}"
This was explained earlier, note that you don't usually need sigle quotes around the file name that you specify with -f, because most file names don't contain any of the shell's special charaters.Notice that in advice, the awk program don't have single quotes around it, the quotes are only need for programs that are provied on the awk command line.
If you want to identify your awk program files clearly as such, you can add the extension .awk to the file name, this doesn't affect the execution of awk program but it does make housekeeping easier.
- awk study(2)
- awk study(1)
- awk study(3)
- awk study(4)
- awk study(5)
- awk study(6)
- awk study(7)
- awk study(9)
- awk study(10)
- awk study(11)
- AWK study note
- awk-2
- awk(2) awk 中的指令
- VBA Study(2)
- Study EJB (2)
- Log4j Study(2)
- OpenGL Study 2
- lucene study notes (2)
- 简单的Java图像处理程序
- Visual C++ 6.0编译指示
- 转载:08年风靡全球八大健身潮流
- 静坐常思己过 闲谈莫论人非
- 狼文化
- awk study(2)
- 网管还需要培训吗?
- 大家好。
- 防止Javascript造成IE内存泄漏的若干原则
- PCM-30标准型综合业务交叉复用设备
- PCM-240系列综合业务交叉复用设备,集中型
- PCM-16精简型综合业务交叉复用设备
- 4E1 PDH 光端机
- 4E1+100M PDH光端机