This will accomplish what you ask:
awk -F';' '{print $1 ";" $2 ";" $3;}' <input >output
The awk
utility is well designed for this task. It can easily cut up individual lines into fields, then manipulate them based on that. The -F';'
argument tells awk
to use ;
as the field separator. The quotes are necessary because the shell would interpret ;
as a command separator without them.
The command given to awk to execute for each line (the '{print $1 ";" $2 ";" $3;}'
bit) is similarly quoted to keep all the funny characters ({
, }
, $
, "
and ;
in this case) from being treated specially by the shell and make sure the whole thing is passed to awk
as one unit.
And, of course, <input
and >output
are the redirection directives being given to the shell to redirect the command's input and output from and to a file.