ChinaUnix.net
相关文章推荐:

shell 字符串比较

#!/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)

相关讨论

本人对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 阅读(27962) 回复(23)

看了前面的一篇关于从文件读取一行到变量中想到的一个问题。 在文件中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 阅读(1137) 回复(8)

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

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

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

by jason.wang - Shell - 2004-11-04 17:44:04 阅读(1906) 回复(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 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)

"2008-4-2" 怎样变成 2008-4-2 也就是把分号去掉

by qwldcl - Shell - 2008-05-19 13:35:25 阅读(3495) 回复(10)

关于shell中的字符串。 比如 #test="abc def" 现在要得到"abc"怎么做呢? #echo ${test%% *} abc 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/17004/showart_469647.html

by shiwudao - HP文档中心 - 2008-01-22 22:52:17 阅读(1562) 回复(0)

我的系统是redhat linux9.0 1 所有数据存放在mysql数据库中 2 把数据库中的数据变成文本数据,便于shell处理 但我现在遇到了下面的问题: 我使用了$mysql_path/mysql -u$mysql_user -p$mysql_password -e "use $mysql_database; $sql_switch"|sed 1d|sed 's/ //g'后,还会得到如下结果: 10.10.1.26 | 1 | public | Uplink_10.10.1.15| 我发现,它们之间不是空格,而是tab或是别的字符来的...

by netpat - Shell - 2005-04-01 15:25:45 阅读(1114) 回复(2)