24小时热门版块排行榜    

Znn3bq.jpeg
查看: 1506  |  回复: 5

probao

铁虫 (初入文坛)

[交流] 开始学习shell 已有5人参与

最近对shell产生了浓厚的兴趣想系统地学习一下,并在小木虫记录下自己的学习过程。
先记录些以前的总结
grep
grep '[[:lower:]]' filename #lower-alpha
grep '\(ab\)\(cd\)[def]*\2\1 #find ab then cd then [def] then cd than ab houxiangyinyong

sed
sed 's/Tolstoy/Camus/' filename        #just change the first one
sed 's/Tolstoy/Camus/g' filename       #change all
sed 's/Tolstoy/Camus/2' filename       #change the second one
sed -n '3,5p' filename                 #print from line 3 to 5
sed '/xixi/,/haha/ s/baz/quux/g' filename   #find lines containing xixi and haha
                                            #then replace baz with quux in these lines
sed '/used/! s/new/used/g' filename    #find lines not containing used
sed '/^#/d' filename | sort > filename.sorted        #find lines containg # at the beginning
                                                #then delet

tail
tail -7 filename                       # print last 7 lines
tail -7 filename > 1                   # print last 7 lines in 1

cut
cut -b 3 filename                     # print the third byte from each line
cut -d : -f 1 filename                # -d customized separator -f field


joint
joint file1 file2                      # file1 and file2 should be in the same format
joint -a1 file1 file2                      # show the difference in file1


awk
awk -F: '{print $1,$2}' filename      # F--field separator print field 1 and 2
awk -F: -v 'OFS=**' '{print $1,$2}' filename        # v--variable OFS--output field sparator

sort
sort filename                              # sort according to ASCII
sort -u filename                      # sort according to ASCII and then delete repeated term
sort -r filename                      # descending order
sort filename -o filename              # sort and then print in the same file
sort -n filename                      # sort according to the number
sort -n -t : -k 2 filename              # -n sort according to the number -t consider colon as separator -k which row

uniq
sort latin-numbers | uniq              # no repeated lines
sort latin-numbers | uniq -c          # recorf repeated time
sort latin-numbers | uniq -d              # show the repeated term
sort latin-numbers | uniq -u          # show the non-repeated term

wc
wc -c                                      # calculate the number of bytes
wc -l                                      # calculate the number of lines
wc -w                                      # calculate the number of words
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

哈哈
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

qchem

铁杆木虫 (著名写手)


有心人
2楼2016-01-24 16:56:48
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

Friday

新虫 (初入文坛)


小木虫: 金币+0.5, 给个红包,谢谢回帖
shell是linux嘛?windows能用吗?

发自小木虫Android客户端
3楼2016-01-24 17:09:50
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

fmying

银虫 (小有名气)


小木虫: 金币+0.5, 给个红包,谢谢回帖
引用回帖:
3楼: Originally posted by Friday at 2016-01-24 17:09:50
shell是linux嘛?windows能用吗?

一般说shell都是Linux的。
Windows的黑框虽然也是个shell,但是功能实在过渣。PowerShell的功能也非常有限,可能适合MS的一些管理工作,但是功能的丰富和强大上绝对达不到Linux的等级的。
上善若水
4楼2016-01-24 22:01:33
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

virtualzx

木虫 (著名写手)


小木虫: 金币+0.5, 给个红包,谢谢回帖
引用回帖:
3楼: Originally posted by Friday at 2016-01-24 17:09:50
shell是linux嘛?windows能用吗?

总的来说使用windows除了游戏和盗版软件多外,百害无一利,如果从事科学计算还要用windows只能说是非要自找麻烦了

发自小木虫IOS客户端
5楼2016-01-25 01:27:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

171808111

新虫 (初入文坛)


小木虫: 金币+0.5, 给个红包,谢谢回帖
我还以为是shelex

发自小木虫Android客户端
科研之路
6楼2016-01-25 02:09:35
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 probao 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 求调剂288 +5 ioodiiij 2026-04-10 7/350 2026-04-10 15:49 by ioodiiij
[考研] 人工智能320调剂08工类还有机会吗 +6 振—TZ 2026-04-10 6/300 2026-04-10 15:19 by zl8213662
[考研] 282,电气工程专业,求调剂,不挑专业 +9 jggshjkkm 2026-04-10 9/450 2026-04-10 14:55 by 逆水乘风
[考研] 292求调剂 +9 笑笑袁 2026-04-09 9/450 2026-04-10 10:05 by LHGeng
[考研] 080100力学316求调剂 +7 L_Hairui 2026-04-07 7/350 2026-04-10 09:45 by vgtyfty
[考研] 一志愿双非085400电子信息344 求调剂,对材料和化学方向也感兴趣 +8 无情的小羊 2026-04-09 9/450 2026-04-10 09:30 by 松花缸1201
[考研] 301求调剂 +4 XYPLR 2026-04-05 6/300 2026-04-10 09:17 by Delta2012
[考研] 297求调剂 +27 GENJIOW 2026-04-07 30/1500 2026-04-09 23:20 by wolf97
[考研] 调剂 +8 只叙离别辞 2026-04-09 10/500 2026-04-09 20:25 by zl8213662
[考研] 337求调剂 +4 Gky09300550, 2026-04-09 4/200 2026-04-09 17:18 by 帕尔马拉特
[考研] 化学工程与技术专业一志愿哈工程 291分B区 国家级大创负责人 有一作论文 +13 Emmy~ 2026-04-09 13/650 2026-04-09 14:47 by only周
[考研] 328求调剂 +17 lftmya 2026-04-07 18/900 2026-04-09 08:05 by 5268321
[考研] 353求调剂 +8 晴空万里air 2026-04-07 8/400 2026-04-09 00:18 by GouQ
[考研] 304求调剂 +16 c297914 2026-04-05 17/850 2026-04-08 13:00 by grayjzr
[考研] 生物医药调剂|SCI中科院三区一作+多项科研成果 +8 likangxing 2026-04-07 11/550 2026-04-08 00:02 by lys0704
[考研] 277求调剂 数一104分 +9 瓶子PZ 2026-04-05 14/700 2026-04-07 17:52 by 蓝云思雨
[考研] 305分求调剂 +3 哈_哈_哈_哈_哈 2026-04-04 5/250 2026-04-07 14:49 by 哈_哈_哈_哈_哈
[考研] 297分083200求助 +9 aekx 2026-04-05 9/450 2026-04-06 20:57 by flysky1234
[考研] 求调剂 +11 xzghyuj 2026-04-04 11/550 2026-04-06 11:49 by lijunpoly
[考研] 22408,264求调剂 +3 ywh729 2026-04-03 4/200 2026-04-04 11:04 by ywh729
信息提示
请填处理意见