cut
In this page:
cut
cut extracts specific columns or character ranges from each line of input, using -d to set a delimiter and -f to choose fields. It's a lighter-weight alternative to awk when you only need to pull out one or two fields. cut -c extracts by character position instead of delimiter-separated fields.
Note: Use cut -d, -f2 to extract the second comma-separated field from CSV-style lines.
Example: 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
🔒
Chapter Quiz — Complete all 12 topics to unlock
0/12 topics done
Complete these topics first: