cut कमांड
cut text की एक table से एक column snip out करने के लिए scissors उपयोग करने जैसा है। आप इसे बताते हैं कि columns को क्या separate करता है और आपको कौन सा column number चाहिए।
In this page:
Syntax
cut -d'delimiter' -f field_number
cut -c start-end
cut
cut input की हर line से specific columns या character ranges extract करता है, delimiter set करने के लिए -d और fields चुनने के लिए -f उपयोग करते हुए।
जब आपको सिर्फ एक या दो fields निकालनी हों तो यह awk का एक lighter-weight alternative है। cut -c delimiter-separated fields के बजाय character position से extract करता है।
Note:
CSV-style lines से second comma-separated field extract करने के लिए
cut -d, -f2 उपयोग करें।उदाहरण: cut
#!/bin/bash
echo "alice,30,engineer" | cut -d, -f1
echo "alice,30,engineer" | cut -d, -f2,3
Login to try C/C++/Java/PHP code in the editor
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
cut -dको एक multi-character delimiter के साथ उपयोग करना, जो allowed नहीं है।- Multiple spaces वाले space separated data पर
-ffields उपयोग करना, जबcutहर space को एक delimiter मानता है। - Delimiter भूल जाना, इसलिए default tab उपयोग होता है।
🔒
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: