Description
- Given a list whose members are separated by spaces.
- If there are several instances of a given member,
we want to keep only the first one and remove the others.
|
| Raw Input
| perl sed awk sed python ada c++ ruby sed c++ lisp
|
|
| Desired Output
| perl sed awk python ada c++ ruby lisp
|
|
Script and Comments
Script1 [ 1] s/^/\n/
[ 2] :0
[ 3] s/\n( *[^ ]+)/\1\n/
[ 4] :1
[ 5] s/([^ ]+)\n(|.* )\1( +|$)/\1\n\2/
[ 6] t 1
[ 7] /\n *$/!b 0
[ 8] s/\n//
| |
|