24小时热门版块排行榜    

Znn3bq.jpeg
查看: 1508  |  回复: 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的回帖

Friday

新虫 (初入文坛)


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

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

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的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料与化工调剂 +11 否极泰来2026 2026-04-10 12/600 2026-04-10 22:03 by 猪会飞
[考研] 本科211 工科085400 280分求调剂 可跨专业 +10 LZH(等待调剂中 2026-04-10 10/500 2026-04-10 21:47 by fxue1114
[考研] 材料与化工300求调剂 +34 肖开文 2026-04-09 37/1850 2026-04-10 18:58 by HPUCZ
[考研] 一志愿矿大,材料工程专硕314分,0856可调都可以 +15 无懈可击的巨人 2026-04-09 15/750 2026-04-10 18:10 by hmn_wj
[考研] 本9 一志愿西工大085601 324求调剂 +5 wysyjs25 2026-04-10 5/250 2026-04-10 16:57 by luoyongfeng
[考研] 085404 298分求调剂 +10 呼啦呼啦呼呼呼 2026-04-10 11/550 2026-04-10 16:44 by wangy0907
[考研] 22408调剂求助 +5 毂12 2026-04-09 7/350 2026-04-10 16:32 by 高维春
[考研] 293调剂 +25 yj1221 2026-04-08 26/1300 2026-04-10 15:02 by 柴小白
[考研] 296求调剂 +12 汪!?! 2026-04-08 13/650 2026-04-10 12:09 by 汪!?!
[考研] 085402通信工程调剂,有4项学科竞赛国奖(电赛国二),硕士研究生调剂自荐信。 +4 m永o不v言o弃m 2026-04-09 4/200 2026-04-10 11:30 by asy1wn
[考研] 085600材料与化工专硕329 求调剂 +24 额cc 2026-04-06 25/1250 2026-04-09 16:01 by wp06
[考研] 286求调剂 +19 Faune 2026-04-08 20/1000 2026-04-09 08:36 by 哦哦123
[考研] 327求调剂 +10 Xxjc1107. 2026-04-06 11/550 2026-04-09 01:21 by lature00
[考研] 285求调剂 +20 哦呦呼o 2026-04-04 20/1000 2026-04-08 22:23 by yutian743
[考研] 考研求调剂 +4 雯??? 2026-04-08 4/200 2026-04-08 21:44 by 土木硕士招生
[考研] 计算机11408 287 求调剂 +3 LiLe5 2026-04-07 3/150 2026-04-07 23:15 by shanqishi
[考研] 285求调剂 +15 哦呦呼o 2026-04-04 17/850 2026-04-06 23:02 by chenzhimin
[考研] 322求调剂 +3 嗯哼哼恒 2026-04-05 3/150 2026-04-05 19:52 by nepu_uu
[考研] 284求调剂 +7 徐同学_001 2026-04-04 13/650 2026-04-05 17:19 by yulian1987
[考研] 可跨专业调剂 +3 周的得地 2026-04-04 6/300 2026-04-04 22:21 by barlinike
信息提示
请填处理意见