awk 'BEGIN{ string="Hello, World!"; print tolower(string); }' 输出: 代码语言:javascript 代码运行次数:0 运行 AI代码解释 hello, world! 代码语言:javascript 代码运行次数:0 运行 AI代码解释 awk 'BEGIN{ string="Hello, World!"; print toupper(string); }' 输出: 代码语言:javascript 代码运行次数...
tolower( String ) 返回String 参数指定的字符串,字符串中每个大写字符将更改为小写。大写和小写的映射由当前语言环境的 LC_CTYPE 范畴定义。 $ awk 'BEGIN { str = "HELLO, WORLD !!!" print "Lowercase string = " tolower(str) }' 输出结果为: Lowercase string = hello, world !!! toupper( String...
和awk变量一样,awk函数可以分为内置函数和自定义函数。 1) 常见awk内置数值函数 int(x) : 求出x 的整数部份,朝向0 的方向做舍去。eg: int(3.9)是3,int(-3.9) 是-3。 sqrt(x) : 求出x 正的平方根值。eg: sqrt(4)=2 exp(x) : 求出x 的次方。eg: exp(2) 即是求e*e 。 log(x) : 求...
function question(){ ind = int(rand()* n) + 1 #以随机数选取考题 system("clear") print " Press \"ctrl-d\" to exit" printf("\n%s ", Chinese[ind] " 的英文生字是: ") } ' $* 执行时键入如下指令 : $./c2e test.dat 屏幕将产生如下的画面: Press "ctrl-d " to exit 莲雾 的英文...
tolower(string):将string中的大写字符转换成小写。 toupper(string):将string中的小写字符转换成大写。 print:输出函数。 rand():返回一个0到1之间的随机数。 system():将传递来的字符串按shell命令执行。 atan2(x, y):反正切函数。 cos(x):余弦函数。
toupper和tolower函数可用于字符串大小间的转换,该功能只在gawk中有效。格式如下: toupper( string ) tolower( string ) 实例: $awk '{ print toupper("test"), tolower("TEST") }' split函数可按给定的分隔符把字符串分割为一个数组。如果分隔符没提供,则按当前FS值进行分割。格式如下: ...
if x is out of range. The range of values x can have depends on your machine's floating-point representation.int(x)Return the nearest integer to x, located between x and zero and truncated toward zero. For example, int(3) is 3, int(3.9) is 3, int(-3.9) is -3, and int(-...
awk是一种编程语言,用于在linux/unix下对文本和数据进行处理。数据可以来自标准输入(stdin)、一个或多个文件,或其它命令的输出。它支持用户自定义函数和动态正则表达式等先进功能,是linux/unix下的一个强大编程工具。它在命令行中使用,但更多是作为脚本来使用。awk有很多内建的功能,比如数组、函数等,这是它和C语言...
toupper和tolower函数可用于字符串大小间的转换,该功能只在gawk中有效。格式如下: toupper( string ) tolower( string ) 1. 2. 实例: $ awk '{ print toupper("test"), tolower("TEST") }' 1. 14.8.2. 时间函数 systime函数返回从1970年1月1日开始到当前时间(不计闰年)的整秒数。格式如下: ...
int(expr) log(expr) rand sin(expr) sqrt(expr) srand([expr]) 字符串函数 asort(arr [, d [, how] ]) asorti(arr [, d [, how] ]) gsub(regex, sub, string) index(str, sub) length(str) match(str, regex) split(str, arr, regex) ...