ChinaUnix.net
相关文章推荐:

awk 与bash位置参数冲突

小弟写了个脚本名叫ak.sh 1、通过shell,给ak.sh 一个位置参数。如:在shell中输入:[code]./ak.sh hello[/code]实现的功能如下: 1、回显一个数字“3” 2、然后用命令管道符配合awk进行判断,如果是3,那么打印显示:“hello不是3”(注:hello为ak.sh后面的位置参数,为$1,后面的3是echo回显后传递给awk的$1),这样就有个问题,里面2个$1,后面一个可能把前面一个$1给覆盖掉了。如果我想既显示hello,又想显示3,如何实现? 我...

by bigfee - Shell - 2011-08-03 08:08:41 阅读(4336) 回复(6)

bash位置参数重复

相关讨论

awk语句写在一个bash脚本里,在awk匹配时需要匹配的字符是由bash传入的参数,请问这个参数怎么写在awk的匹配字符里。 比如bash脚本获得一个参数,存在$1中,在调用awk时,想以$1匹配,但是如果把$1写进去,awk读的是自己分隔符的一个参数,有没有什么方法?区分这两种$1

by turkeyNUPT - Shell - 2009-04-29 15:39:33 阅读(3431) 回复(6)

bash shell中的位置参数$#,$*,$@,$0,$1,$2...及特殊参数$?,$-等的含义 在bash shell中经常会见到一些比较特殊的符号,本人现收集与此,以供查阅: 位置参数: 详见ABS(Advanced bash Shell)中文翻译版103页第9章第一节内部变量,当然英文版ABS都一样啦 $1, $2, $3等等... 位置参数,从命令行传递给脚本,或者是传递给函数.或者赋职给一个变量. 此数目可以任意多,但只有前9个可以被访问,使用shift命令可以改变这个限制。 (具体见Ex...

by yanzhiyi1012 - Linux文档专区 - 2010-07-07 14:22:38 阅读(1760) 回复(1)

请问如何用awk将a文件中ap行中的zzz放前面列 又不影响ve行,输出结果文件b a: ap a1 a1 x1 y1 zzz ve a1 0 10 20 30 40 50 60 ve 70 80 90 100 101 102 103 ap a2 a2 x2 y2 zzz ve a2 0 10 20 30 40 50 60 ve 70 80 90 100 101 102 103 ap a3 a3 x3 y3 zzz...

by 竹熊猫 - Shell - 2015-05-07 17:22:32 阅读(2135) 回复(7)

文件sql.cfg内容如下: dailypaymentusers "select count(distinct xid) from payment where create_time>(unix_timestamp()*1000-24*3600000) and state>=2" dailypaymentcount "select count(*) from payment where create_time>(unix_timestamp()*1000-24*3600000) and state>=2" mining.sh脚本的内容: #bin/bash awk '{system(echo 'sql.cfg的第一个字段 '`mysql -u 位置参数1 -p 位置参数2 位置参数3 -e "sql.cfg的第...

by greendays - Shell - 2010-06-08 15:48:57 阅读(4933) 回复(4)

各位,请教一个问题。 有一文本文件格式如下:(日期|种类|金额) 20060102|车工|63.36 现在我想用set命令结合awk命令将文件中的第一个字段定义到$1,第二个字段定义到$2,第三个字段定义到$3中去,怎样实现?

by likfan - Shell - 2006-05-08 08:17:28 阅读(1454) 回复(1)

Compound Commands A compound command is one of the following: (list) list is executed in a subshell environment (see COMMAND EXECU- TION ENVIRONMENT below). Variable assignments and builtin com- mands that affect the shell's environment do not remain in effect after the command completes. The return status is the ...

by iamkey9 - Shell - 2007-09-24 14:46:24 阅读(1434) 回复(2)

我想通过管道做一系列处理最后得到的字符串赋值给一个变量,但是我在var="${str=expr}"里面使用管道,bash参数过多,求教如何搞定?

by J_O_H_N - Shell - 2011-11-09 15:01:59 阅读(4554) 回复(11)

PPID : 该bash的呼叫者process ID. PWD : 目前的工作目录。 OLDPWD : 上一个工作目录。 REPLY : 当read命令没有参数时,直接设在REPLY上。 UID : User ID。 EUID : Effective User ID。 bash : bash的完整路径。 bash_VERSION : bash版本。 SHLVL : 每次有bash执行时,数字加一。 RANDOM : 每次这个参数被用到时,就会产生一个乱数在RANDOM上。 SECONDS : 从这个Shell一开始启动後的时间。 LINENO : Script的行数。 H...

by wflai - Linux文档专区 - 2007-09-02 22:40:48 阅读(651) 回复(0)

本帖最后由 ckf513728912 于 2014-02-28 16:48 编辑 linux-txyf:/home/suse/coco/shell # lspci | grep -i "vga" 01:00.0 VGA compatible controller: nVidia Corporation Device 1049 (rev a1) linux-txyf:/home/suse/coco/shell # lspci -v -s 01:00.0 01:00.0 VGA compatible controller: nVidia Corporation Device 1049 (rev a1) (prog-if 00 [VGA controller]) Subsystem: Micro-Star International Co., Ltd. Device 2...

by ckf513728912 - Shell - 2014-03-02 21:15:13 阅读(1136) 回复(9)

有一个简单的txt a.txt aaa bbb ccc ddd 有一个test.sh temp=$1 answer=` awk ' { if ( $1 == $temp ) print $2 ; }' a.txt ` echo $answer run: ./test.sh aaa 但是我发现$temp可以读到,但是不能和 $1 比较,awk 似乎认不到他,请问大家有什么办法呢? 先谢谢了

by chinasg - Linux系统管理 - 2010-12-03 14:23:05 阅读(4445) 回复(4)