Fish Shell:
पैटर्न से मेल खाते अक्षरों को हटाना
How to: (कैसे करें:)
# एक स्ट्रिंग से सभी अंक हटाने का उदाहरण
echo "Fish123Shell456" | string replace -ar "[0-9]" ""FishShell# फ़ाइल के नाम से विशेष वर्णों को हटाना
for file in *
mv $file (echo $file | string replace -ar "[@#$%^&*()]" "")
endउपरोक्त कोड फ़ाइल्स के नाम से @#$%^&*() इन विशेष वर्णों को हटा देगा।
Deep Dive (गहराई में जानकारी)
Fish Shell में string कमांड टेक्स्ट प्रोसेसिंग के लिए सबसे उपयोगी टूल्स में से एक है। ‘string replace’ का उपयोग कर कोई भी पैटर्न डिलीट करना आसान है। पहले लोग sed और awk जैसे टूल्स का उपयोग करते थे, लेकिन Fish में बिल्ट-इन string कमांड की वजह से यह काम बहुत सटीक और सहज हो गया है। ‘string replace -ar’ का मतलब है ‘all occurrences’ (सभी उदाहरणों को) ‘regular expression’ (रेगुलर एक्सप्रेशन के द्वारा) से रिप्लेस करना।
See Also (और जानकारी के लिए)
- Fish Shell Documentation: fishshell.com/docs/current/index.html
- String Manipulation with Fish: fishshell.com/docs/current/cmds/string.html
- Regular Expressions Introduction: regular-expressions.info