The "cut" command is what you're looking for...
Basic example given the following data in a file "input.txt":
Tang:Sam:90:40:40
Dylan:Tom:80:48:50
Smith:John:34:67:89
Find Sam Tang's first name only:
grep Tang input.txt | cut -d':' -f2
grep pulls just the line you want, then cut is passed two parameters: -d (delimiter, which in this case is set to ':') and -f (field, which in this case is "field" #2). If I used this command on /etc/passwd in this form:
snippet from /etc/passwd:
Code:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/bin/false
operator:x:11:0:operator:/root:/bin/bash
grep root /etc/passwd | cut -d':' -f1-2 --output-delimiter=" "
I get this:
root x
operator x
Edit: You can also accomplish this with sed or awk...I'll give a basic sed example (awk would be much easier!):
sed -e 's/\([A-Za-z]*\):\([A-Za-z]*\):\([0-9]*\):\([0-9]*\):\([0-9]*\)/First Name: \1\nLast Name: \2\nExercise 1: \3\nExercise 2: \4\nCase Study: \5\n/g' input.txt