Using Perl
~$ perl -lane ' @F = split(";"); print join ";", @F[0..2];' file
Using Raku (formerly known as Perl_6)
$~ raku -ne 'my @F = .split(";"); put join ";", @F[0..2];' file
Here are two answers using Perl and Raku, respectively. Data is read-in linewise using the Perl -lane or Raku -ne non-autoprinting flags. (The difference is Raku performs the -l autochomping by default, however Raku doesn't have the -a flag).
After this, the code is virtually identical. In Raku you have to declare the @F (or @G, or @H array, etc.) with my or our (scope descriptor). Also Raku demands that you indicate what object you're calling split on (.split is short for $_.split meaning the $_ topic variable, which holds individual lines of data as they are read-in).
Finally you either print (Perl) or put (Raku). Raku has print as well, but put adds a newline terminator for you.
Sample Input:
1;foo;bar;baz;x;y;z
2;foo;bar;baz;x;y;z
3;foo;bar;baz;x;y;z
Sample Output:
1;foo;bar
2;foo;bar
3;foo;bar
Perl References:
https://perldoc.perl.org
https://www.perl.org
Raku References:
https://docs.raku.org
https://raku.org
cut. :-) – Omnifarious Nov 13 '12 at 17:56cut -d \; -f 3? – gt6989b Nov 13 '12 at 19:34-3says to print all fields up to and including the third field. – Chris Down Nov 13 '12 at 19:41-f 1-3, this is a useful shortcut. – gt6989b Nov 13 '12 at 20:54