Picking a character from a word
Juergen Wagner
gandalf at csli.STANFORD.EDU
Sat Apr 23 12:47:36 AEST 1988
How about
sed 's/^...\(.\).*/\1/'
which extracts the fourth character of a string read from stdin.
More general (and more ugly):
awk '{print substr($0,4,1);}'
which allows you to pick an arbitrary substring from the lines on stdin.
If you are using this very often, I suggest to write a small C program
doing the job (string manipulation). Awk and sed are not very fast.
--
Juergen "Gandalf" Wagner, gandalf at csli.stanford.edu
Center for the Study of Language and Information (CSLI), Stanford CA
More information about the Comp.unix.questions
mailing list