24小时热门版块排行榜    

Znn3bq.jpeg
查看: 1509  |  回复: 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的回帖
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料与化工300求调剂 +35 肖开文 2026-04-09 38/1900 2026-04-10 22:59 by Ftglcn90
[考研] 调剂 +19 小张ZA 2026-04-10 20/1000 2026-04-10 22:08 by 猪会飞
[考研] 295分求调剂 +6 ?要上岸? 2026-04-10 6/300 2026-04-10 21:13 by chemisry
[考研] 263能源动力专硕求调剂 +4 加大号饭盒袋 2026-04-10 4/200 2026-04-10 20:52 by gong120082
[考研] 机械还有还有名额吗?太难了 +6 笑笑袁 2026-04-10 6/300 2026-04-10 11:54 by 高维春
[考研] 一志愿 江南大学 085602 化工专硕 338分求调剂 +16 路痴小琪 2026-04-05 16/800 2026-04-10 08:08 by kangsm
[考研] 一志愿电子科技大学085600材料与化工 329分求调剂 +14 Naiko 2026-04-04 14/700 2026-04-09 16:56 by luoyongfeng
[考研] 070300化学学硕311分求调剂 +18 梁富贵险中求 2026-04-04 20/1000 2026-04-09 11:18 by 哒哒哒呱呱呱
[考研] 一志愿华南师范大学0702物理学305调剂 +4 念常安 2026-04-07 6/300 2026-04-08 22:53 by bljnqdcc
[考研] 考研求调剂 +4 雯??? 2026-04-08 4/200 2026-04-08 21:44 by 土木硕士招生
[考研] 材料专硕(0856) 339分求调剂 +16 哈哈哈鹅哈哈哈 2026-04-05 16/800 2026-04-08 16:02 by luoyongfeng
[考研] 电子信息346 +4 zuoshaodian 2026-04-08 4/200 2026-04-08 11:54 by zzucheup
[考研] 调剂 +3 电气300求调剂不 2026-04-08 6/300 2026-04-08 09:39 by 电气300求调剂不
[考研] 312求调剂 +4 Say Never 2026-04-04 4/200 2026-04-08 08:41 by barlinike
[考研] 285求调剂 +15 哦呦呼o 2026-04-04 17/850 2026-04-06 23:02 by chenzhimin
[考研] 考研调剂 +3 Wwwwwww哇 2026-04-06 3/150 2026-04-06 20:55 by lbsjt
[考研] 材料与化工363求推荐 +11 zh096 2026-04-04 11/550 2026-04-06 19:14 by guanxin1001
[考研] 一志愿安徽某211 0703化学总分339求调剂 +7 晚风不晚 2026-04-04 7/350 2026-04-06 14:06 by houyaoxu
[考研] 085600,320分求调剂 +16 大馋小子 2026-04-04 17/850 2026-04-06 07:58 by MOF_Catal
[考研] 男生,一志愿沪9生物学071000,初试308求调剂 +3 刘墨墨 2026-04-04 3/150 2026-04-05 08:26 by barlinike
信息提示
请填处理意见