本人对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 为什么??
在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下子字符串如何比较,上面的应如何修正?
看了前面的一篇关于从文件读取一行到变量中想到的一个问题。 在文件中a.file的内容如下: /dev/device1 abc /dev/device2 def /dev/device3 abc /dev/device11 dfe 这种情况下,中间有空行。我想从文件a.file中读到每一行的devicex,然后保存到变量中。使用循环的方式。每次读一行,读到之后,就将devicex的值(就是device(1-3))保存到变量var中,然后就是对var这个变量中的值devicex进...
在文件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_...