fd - `find` का सरल, तेज़ और user-friendly विकल्प
(github.com/sharkdp)fdफ़ाइल सिस्टम में आइटम खोजने का एक प्रोग्राम है, जो पारंपरिकfindकमांड का एक सरल, तेज़ और user-friendly विकल्प है- यह
findकी सभी सुविधाओं को सपोर्ट नहीं करता, लेकिन सामान्य उपयोग के मामलों के लिए समझदारी भरे default प्रदान करता है
- यह
- Windows, macOS, Linux
- सहज syntax:
fd PATTERNफ़ॉर्म में आसानी से उपयोग किया जा सकता है (find -iname '*PATTERN*'से अधिक सुविधाजनक) - regular expression और glob pattern सपोर्ट
- parallel directory traversal के ज़रिए तेज़ performance
- फ़ाइल प्रकार के अनुसार color highlighting (
lsकी तरह) - parallel command execution सपोर्ट
- smart case sensitivity: डिफ़ॉल्ट रूप से case ignore करता है, लेकिन uppercase शामिल होने पर case-sensitive बन जाता है
- hidden files और directories को डिफ़ॉल्ट रूप से ignore करता है
.gitignorepattern को डिफ़ॉल्ट रूप से मानता है- कमांड का नाम
findसे 50% छोटा है
उपयोग
- वर्तमान directory में pattern वाले आइटम खोजें
fd netfl - regular expression का उपयोग करके खोजें
fd '^x.*rc$' - किसी विशेष directory में खोजें
fd passwd /etc - वर्तमान directory के नीचे सभी files को recursively list करें
fd - किसी विशेष file type को खोजें (-e option का उपयोग)
fd -e md - सटीक filename खोजें (-g option का उपयोग)
fd -g libc.so /usr - hidden files और ignored files सहित खोजें (-H, -I option का उपयोग)
fd -H pre-commitfd -I num_cpu - filename नहीं, पूरी path में खोजें (-p option का उपयोग)
fd -p '.*/lesson-\d+/[a-z]+.(jpg|png)' - हर search result पर कमांड चलाएँ (-x)
fd -e zip -x unzip - सभी search results को एक ही कमांड को दें (-X)
fd -g 'test_*.py' -X vim - placeholder syntax
- {}: search result का पूरा path
- {.}: file extension के बिना path
- {/}: filename
- {//}: parent directory
- {/.}: filename से extension हटाकर
- किसी विशेष directory या file को exclude कर सकते हैं (-E option का उपयोग)
fd -H -E .git .fdignoreफ़ाइल बनाकर global exclude pattern सेट कर सकते हैं- खोजी गई files delete कर सकते हैं (-X rm)
fd -H '^\.DS_Store$' -tf -X rm
मुख्य कमांड options
- -H: hidden files और directories सहित खोज
- -I: .gitignore और .fdignore को ignore करें
- -p: पूरी path में खोज
- -e: किसी विशेष extension की खोज
- -x: search result पर कमांड चलाएँ
- -X: सभी search results को एक ही कमांड को दें
- -E: किसी विशेष file या directory को exclude करें
प्रदर्शन तुलना (Benchmark)
- 750,000 directories और 40 लाख files पर search test के परिणाम
- find performance: लगभग 19.9 सेकंड
- fd performance: लगभग 854.8ms
findसे 23 गुना तेज़
दूसरे प्रोग्रामों के साथ integration
fdsearch result कोfzfमें दिखाया जा सकता हैexport FZF_DEFAULT_COMMAND='fd --type file'fdoutput कोrofiमें मेनू के रूप में दिखाएँfd --type f -e pdf . $HOME | rofi -dmenu- output को tree structure में दिखाएँ
fd | tree --fromfile - search result को
xargsमें उपयोग करेंfd -0 -e rs | xargs -0 wc -l
2 टिप्पणियां
neovim plugin में से एक
fdइस्तेमाल करता है, इसलिए मैंने इसे इंस्टॉल किया था और तब से अब तक यही इस्तेमाल कर रहा हूँ, हाहा.Hacker News टिप्पणियाँ
find . | grep what_i_am_looking_forइस्तेमाल करता हूँ