
Shell
楓尘林间
计算机爱好者
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[转载]Linux下更改正确国内时间
Linux使用小Tips Linux下设置时间 提供两种最根本有效的方式,就是更改时区。这里以更改为国内上海时间例子,其他地方时区同理。 方法一 备份文件 mv /etc/localtime /etc/localtime.bak 复制时区文件 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 这里选择了亚洲下的上海时区,可ls查看各文件夹下的时区文件。 查看当前时间 date 是否已经是正确时间啦。一般建议使用第二种建立链接方式 方法二 备份文件 mv转载 2020-11-23 14:57:41 · 396 阅读 · 0 评论 -
linux shell下变量赋值
shell脚本基本变量赋值 数值型 a = 0(错误写法) “=“两侧不能有空格 报错:“command not found” a=0(正确写法) 字符串型 b = ”berwin“(错误写法) “=“两侧不能有空格 报错:“command not found” b=“berwin”(正确写法) 运行时就会报错:“command not found”,将空格删除正常运行。 ...原创 2020-01-02 16:26:13 · 1546 阅读 · 0 评论 -
(转载)shell获取函数返回值的两种方法
方法一: 使用全局变量 [html] view plaincopy在CODE上查看代码片派生到我的代码片 g_result="" function testFunc() { g_result='local value' } testFunc echo $g_result 方法二: 把shell函数作为子程序调用,将其结果写到子程序的标准输出 [ht...转载 2019-12-31 22:42:22 · 397 阅读 · 0 评论 -
linux shell计算毫秒间隔
shell 没有直接的毫秒计时单位 只有秒(s)和纳秒(ns) 换算公式: 1s=1000ms 1ms=1000 microseconds 1microsecond=1000 nanoseconds 1 计算秒间隔 starttime=`date +'%Y-%m-%d %H:%M:%S'` endtime=`date +'%Y-%m-%d %H:%M:%S'` start_seconds=$(d...原创 2019-12-31 22:25:54 · 4890 阅读 · 2 评论 -
shell脚本
1、字符串判断 str1 = str2 当两个串有相同内容、长度时为真 str1 != str2 当串str1和str2不等时为真 -n str1 当串的长度大于0时为真(串非空) -z str1 当串的长度为0时为真(空串) str1 当串str1为非空时为真 2、数字的判断 int1 -eq int2 两数相等为真 in...原创 2019-12-06 18:47:33 · 102 阅读 · 0 评论