ChinaUnix.net
相关文章推荐:

Linux shell 字符串比较

本人对shell脚本刚刚接触,请大家指教,见笑了. 用ftp当天备份数据,我想通过比对文件时间并以星期分类存放数据 我想到的方法: cd /ftp ls -la |grep nfsdir |awk '{print $6"\t"$7}' echo `date` | awk '{print $2"\t"$3}' 这两个输出将列出月份和日期,我想对两个结果做个比对,如果相等,则执行cpoy,这个怎么写?能完成以星期分类存放么? [ 本帖最后由 jat_15 于 2009-2-25 11:17 编辑 ]

by jat_15 - Shell - 2009-02-25 15:01:40 阅读(27972) 回复(23)

相关讨论

#!/bin/bash if [ "aabdc"="abc" ] then echo "same" else echo "not same" fi 输出结果为:same 这倒底是为什么呀?为什么这个test命令不能使用呢??? #!/bin/bash STR1=abc STR2=dev if [ "${STR1}"="${STR2}" ] then echo "same" else echo "not same" fi 这个输出结果也是same 为什么??

by cczy - Shell - 2009-02-26 19:49:20 阅读(3261) 回复(13)

在sco unix下, 1.sh文件如下内容: a=$1 b=$2 if [ $a -ge $b ];then echo "A大" else echo "B大" fi #./1.sh 100.00 200.00 结果: B大 运行正常 但在SUSE linux下 出现如下错误 ./1.sh: line 5: [: 200.00: integer expression expected B大 好像正能是整型树才能比较, 请问在linux下子字符串如何比较,上面的应如何修正?

by xianren - Shell - 2006-04-12 15:49:33 阅读(8263) 回复(9)
by xjc2694 - Perl - 2009-08-28 14:14:27 阅读(2571) 回复(8)

shell中,有两个字符串,"2004.05.23" 和"2005.03.01",怎么来比较他们的大小??

by suitar - Shell - 2016-07-20 11:24:39 阅读(10691) 回复(9)

看了前面的一篇关于从文件读取一行到变量中想到的一个问题。 在文件中a.file的内容如下: /dev/device1 abc /dev/device2 def /dev/device3 abc /dev/device11 dfe 这种情况下,中间有空行。我想从文件a.file中读到每一行的devicex,然后保存到变量中。使用循环的方式。每次读一行,读到之后,就将devicex的值(就是device(1-3))保存到变量var中,然后就是对var这个变量中的值devicex进...

by foxwhilter - Shell - 2004-12-04 21:58:40 阅读(1138) 回复(8)

例如: str1="意大利" str2="新西兰" if [str1 -eq str2] 可以吗?能比较出来吗/

by jason.wang - Shell - 2004-11-04 17:44:04 阅读(1907) 回复(5)

shell中为什么在比较字符串的时候要加一个x if test x"$ac_cv_sizeof_size_t" = x"8"; then 谢谢大家!!

by zxq230104 - Shell - 2008-11-03 11:44:05 阅读(3177) 回复(8)
by redor - 程序开发 - 2006-07-27 22:36:09 阅读(1085) 回复(3)
by todayhero - Shell - 2009-01-19 22:16:43 阅读(2483) 回复(8)

在文件table.list中有如下内容, cat table.list ./tempdata/s_job_chain.txt ./tempdata/s_entity_info.txt ./tempdata/s_db_info.txt ./tempdata/s_job_cost.txt ./tempdata/s_datamng_log.txt ./tempdata/s_audit_rule.txt ./tempdata/s_cnode_stat.txt ./tempdata/s_instance_stat.txt ./tempdata/h_instance_info.txt ./tempdata/s_ds_jobparam.txt ./tempdata/s_job_attr.txt ./tempdata/h_job_info.txt ./tempdata/s_refer_...

by legone2008 - Shell - 2008-08-29 02:18:17 阅读(6626) 回复(8)