Extract specific fields with cut
extract column from file linux | show only certain fields cut | split fields by colon | cut | columns | fieldscut -d':' -f1,7 /etc/passwdSplits each line at the delimiter and prints only the requested fields. Fields can be given as a list (1,7), a range (2-4) or open-ended (3-). In the example, the username and login shell of all accounts are shown.
Note: cut only accepts a single character as delimiter and treats several consecutive spaces as several empty fields. For whitespace-separated output, awk '{print $2}' is better suited.
Also searched as
- extract column from file linux
- show only certain fields cut
- split fields by colon