24小时热门版块排行榜    

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

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的回帖
查看全部 6 个回答

Friday

新虫 (初入文坛)


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

发自小木虫Android客户端
3楼2016-01-24 17:09:50
已阅   回复此楼   关注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的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 280求调剂 +12 李rien 2026-04-04 12/600 2026-04-10 21:19 by zhouxiaoyu
[考研] 284求调剂 +11 archer.. 2026-04-10 12/600 2026-04-10 18:57 by HPUCZ
[考研] 求调剂 +7 璃茉一定上岸 2026-04-10 7/350 2026-04-10 15:25 by jiajinhpu
[考研] 085402通信工程调剂,有4项学科竞赛国奖(电赛国二),硕士研究生调剂自荐信。 +4 m永o不v言o弃m 2026-04-09 4/200 2026-04-10 11:30 by asy1wn
[考研] 0702物理学学硕299求调剂 +6 祁柒连 2026-04-06 6/300 2026-04-10 11:10 by Roomoo
[考研] 材料调剂 +13 一样YWY 2026-04-04 13/650 2026-04-10 11:07 by mattzhming
[考研] 材料299专硕求调剂 +10 +21 2026-04-09 10/500 2026-04-09 17:34 by 1753564080
[考研] 086004 求调剂 309 +7 Yin DY 2026-04-08 7/350 2026-04-09 13:59 by Delta2012
[考研] 求调剂,262机械专硕 +6 嗯yyl 2026-04-08 6/300 2026-04-09 12:01 by zhouyuwinner
[考研] 334求调剂 +16 Riot2025 2026-04-08 17/850 2026-04-09 09:28 by wdyheheeh
[考研] 一志愿北京2,材料与化工308求调剂 +17 熊二想上岸 2026-04-04 18/900 2026-04-09 09:13 by leyan1127
[考研] 化学308分求调剂 +21 你好明天你好 2026-04-07 23/1150 2026-04-08 22:32 by 凯凯要变帅
[考研] 软件工程求调剂22软工296分求调剂,接受跨调 +4 yangchen2017 2026-04-08 5/250 2026-04-08 21:56 by 土木硕士招生
[考研] 材料考研求调剂总分280 +30 mkjlz1 2026-04-06 35/1750 2026-04-08 21:25 by cyh—315
[考研] 298求调剂 +4 manman511 2026-04-05 4/200 2026-04-08 16:50 by tjzhao
[考研] 318求调剂 +5 李青山山山 2026-04-07 5/250 2026-04-07 18:24 by 蓝云思雨
[考研] 081200-11408-367学硕求调剂 +4 1_2_3111 2026-04-06 4/200 2026-04-07 08:13 by jp9609
[考研] 327考研调剂推荐 +6 呜呜呜呜呢 2026-04-06 6/300 2026-04-06 21:39 by 啵啵啵0119
[考研] 求调剂 +7 张.1 2026-04-05 7/350 2026-04-05 20:40 by 啵啵啵0119
[考研] 295求调剂 +4 A你好研究生 2026-04-04 5/250 2026-04-04 22:46 by yu221
信息提示
请填处理意见