开始用zsh(1):globbing
一直不清楚blog的定位是什么,姑且先作为知识的整理和分享好了。
zsh的交互式实在太诱人,反正还没有熟悉bash,还是直接上手zsh好了。切换shell可以直接用chsh -s /bin/zsh
globbing
也就是利用*之类的字符生成多个文件名,除了bsah的模式之外还有一个扩充模式。然后python中也有对应的模块,不知道有什么不同的地方。
基本的模式都很熟悉了:
*.c *.[co] *.[^ch] foo[1-9][0-9]?? mysrc.{c,h} mv {old,new}.c
在默认设置下,zsh可以在在globbing后面加入qualifiers,比如说:
ls -d *(.)
表示只生成plain文件的文件名,其中最后的()里面的是zsh的qualifiers,如果是(@)的话就表示只生成软链文件。下面列举出一些qualifiers,更具体的qualifiers可以参见"man zshexpn"。
- /:目录
- @:软链
- .:plain文件
- %:设备文件,其中%b是指定block设备,%c是char设备
- *:可执行文件(对本用户)
- 权限(就是mod)的过滤,具体有:sStxwrAIEXWR,f???
- ....
如果在qualifiers前面加上^就是相反的意思。
感觉就是,熟悉了qualifiers后find好像可以退休了,不过很多qualifiers都用不着就是了,需要的时候再查查zshexpn的manpage就可以了。
此外zsh还有一个扩展模式,则需要设置EXTENDEDGLOB变量:
setopt extendedglob
下面列出扩展模式的特性:
1. nagative pattern: "^" 和 "~"
在pattern前加上^,就^表示只生成pattern中^后面不符合的文件名。如:
ls -d *.^c
表示只生成后缀不为c的文件名。
在第一个pattern后面加上~和另外一个pattern,表示生成符合第一个pattern不符合第二个pattern的文件名:
ls pattern1~pattern2
2.数字范围
看看example就好:
% ls run<200-300> run234 run240 % ls run<300-400> run303 % ls run<-200> run123 run2 % ls run<300-> run303 % ls run<> run123 run2 run234 run240 run303
3.分组:
% ls (foo|bar).* bar.o foo.c foo.o % ls *.(c|o|pro) bar.o file.pro foo.c foo.o main.o q.c
4.递归搜索子文件夹 **/
ls /path/to/somewhere/**/*.h
几个问题:
1. 扩充失败时会见到:
zsh: no match found: pattern
也就是说找不到适合pattern的文件了。
2. 如果要匹配文件名中的特殊字符,记录要quote,一般用双引号包着就可以。
2011年6月29日 20:31
第一个问题 unsetopt nomatch 即可。
我也没怎么用过 bash。最初看了个 PDF 用了段时间的 fish,后来就转 zsh 了~
2022年9月02日 15:12
HP Board Model Paper 2023 Class 4 Pdf Download with Answers for English Medium, Hindi Medium, Urdu Medium & Students for Small Answers, Long Answer, Very Long Answer Questions, and Essay Type Questions to Term1 & Term2 Exams at official website. HP Board Model Paper Class 4 New Exam Scheme or Question Pattern for Sammittive Assignment Exams (SA1 & SA2): Very Long Answer (VLA), Long Answer (LA), Small Answer (SA), Very Small Answer (VSA), Single Answer, Multiple Choice and etc.
2023年11月01日 19:00
This is a great feature for sharing this informative message. I am impressed by the knowledge you have on this blog. It helps me in many ways. Thanks for posting this again
2023年12月07日 04:50
Crafting exceptional content is the cornerstone of 구글 상위노출 success. It's a combination of art and science that requires dedication and precision.
2023年12月10日 18:37
Anonymity allows me to ask candid questions on 달리머넷. It's a supportive community that encourages curiosity.
2023年12月10日 19:08
청주공항렌트카 - the best way to explore Jeju Island.
2023年12月10日 22:17
티비몬 offers a great variety of shows and movies, making it a go-to platform for entertainment enthusiasts.
2023年12月11日 21:08
오피가이드 makes OP exploration exciting and informative. It's a must-visit for anyone curious about OP services.
2023年12月13日 17:52
제주퍼블릭's transparency in pricing is commendable. No hidden fees, just a fantastic night of fun and luxury.
2023年12月14日 18:41
오피 offers discreet relaxation services, perfect for unwinding after a long day's work. Highly recommended!
2023年12月14日 22:22
안전놀이터 is your gateway to a world of secure gaming excitement.
2023年12月15日 22:13
As someone who used to be skeptical, I can confidently say that 힐링 is the real deal. Give it a chance, and you'll see the difference.
2023年12月16日 13:24
This internet site is really a walk-through its the knowledge you desired about it and didn’t know who need to. Glimpse here, and you’ll absolutely discover it. NBA중계
2023年12月16日 21:47
Choose Tipping if you're serious about quality 설문조사 사이트 추천.
2023年12月24日 03:44
A visit to 수원휴게텔 is a journey to relaxation. The skilled therapists and tranquil setting create an ideal haven for unwinding.
2023年12月26日 00:43
epl무료중계 is my go-to for fantasy football insights, enhancing my fantasy league experience.
2024年1月19日 01:12
Board Model Papers 2024 provide all states of 6th to 10th text books 2024 Candidates who are Searching for 6th to 10th and 11th to 12th text books and syllabus, sample questions, exam pattern, and Co-Curricular Subject textbooks can refer to this entire article. boardmodelpaper.com and question papers for following the website and Arts, Science, Commerce Stream Subject Wise Solved Question Bank for Hindi & English Medium Students with Exam Pattern & Blueprint and subject Wise with 11th & 12th Question Bank 2024 for General & Vocational Course. Here, we have gathered all subjects of Board textbooks for all Class along with the direct download links.
2024年7月10日 20:39
This is because another benefit of modern bulletproof vests is how easy they are to wear, even for extended periods. glock 26 mags with extension
2024年9月16日 22:32
Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!.. Sticky Post Homepage
2024年9月22日 02:09 Awesome and interesting article. Great things you've always shared with us. Thanks. Just continue composing this kind of post. slot gacor gampang menang
2024年9月30日 17:06
You have a good point here!I totally agree with what you have said!!Thanks for sharing your views...hope more people will read this article!!! coloksgp
2024年10月13日 16:32
Wow, What a Excellent post. I really found this to much informatics. It is what i was searching for.I would like to suggest you that please keep sharing such type of info.Thanks traductor confiable de inglés a español
2024年10月28日 10:07
"Jammersignal Cell Phone Signal Jammer is a powerful device for blocking disruptive mobile signals, fostering a quiet and productive environment in areas where concentration is key!" jammersignal Cell Phone Signal Jammer
https://www.jammersignal.com/product-category/cell-phone-signal-jammer/