Extract Column in Shell

Level 239 keystrokes

cut extracts specific columns or fields from lines.

Shell code

# -d':' splits each line at colons; -f1,3 keeps fields 1 and 3
# In /etc/passwd these are the user name and UID; head shows the first 5
1cut -d':' -f1,3 /etc/passwd | head -n 5

Output

root:0
daemon:1
bin:2
sys:3
sync:4
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Shell code and how often they appear.

  • -× 3
  • '× 2
  • /× 2
  • ,× 1
  • :× 1
  • |× 1

More Shell examples at level 2

← Shell typing practice