码迷,mamicode.com
首页 > 系统相关 > 详细

linux 常用命令

时间:2016-10-27 10:28:47      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:date   htm   nbsp   ase   test   name   匹配   执行   内容   

1、小写字母转换大写字母

echo "aBcD"|tr ‘a-z‘ ‘A-Z‘

2、大写字母转换小写字母

echo "aBcD"|tr ‘A-Z‘ ‘a-z‘

3、当前脚本路径

basepath=$(cd `dirname $0`; pwd)

具体详细解释,请看http://www.cnblogs.com/FlyFive/p/3640267.html

4、常用日期变量

date +‘%y%m%d%H%M%S‘

输出格式为:20161027090005

date +‘%y-%m-%d %H:%M:%S‘

输出格式为:2016-10-27 09:00:05

5、sed常用命令

删除匹配test的行

sed -i ‘/test/d‘ /tmp/test.txt

修改/tmp/test.txt的内容test为test1

sed -i ‘s/test/test1/g‘ /tmp/test.txt

如遇到特殊字符,请把/替换为#或者其它字符.例如:sed -i ‘s#test#test1#g‘ /tmp/test.txt

6、行转列

执行命令:cat /tmp/test.txt

输出:

a b c

执行命令:

for parm in $(cat /tmp/test.txt)

do

echo $parm

done

输出结果:

a

b

c

7、列转行

执行命令:cat /tmp/test.txt

输出:

a

b

c

执行命令:cat /tmp/test.txt|xargs -r

输出:

a b c

 

linux 常用命令

标签:date   htm   nbsp   ase   test   name   匹配   执行   内容   

原文地址:http://www.cnblogs.com/dbcloud/p/6002725.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!