-
Notifications
You must be signed in to change notification settings - Fork 1
/
UNIQ.PAS
45 lines (42 loc) · 1.06 KB
/
UNIQ.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{ @author: Sylvain Maltais ([email protected])
@created: 2022
@website(https://www.gladir.com/linux-0)
@abstract(Target: Free Pascal, Turbo Pascal)
}
Program UNIQ(Input,Output);
Var
FileView:Text;
FileName,CurrLine,LastLine:String;
BEGIN
LastLine:='';
If(ParamStr(1)='/?')or(ParamStr(1)='--help')or(ParamStr(1)='-h')Then Begin
WriteLn('UNIQ : Cette commande permet de sortir le contenu d''un ',
'fichiers sans duplication du contenu de ses lignes');
WriteLn;
WriteLn('Syntaxe : UNIQ nomdufichier');
End
Else
If ParamCount>=1Then Begin
FileName:=ParamStr(1);
Assign(FileView,FileName);
{$I-}Reset(FileView);{$I+}
If IoResult=0Then Begin
While Not EOF(FileView)do Begin
ReadLn(FileView,CurrLine);
If LastLine<>CurrLine Then WriteLn(Output,CurrLine);
LastLine:=CurrLine;
End;
End
Else
WriteLn('Erreur de lecture du fichier');
Close(FileView);
End
Else
Begin
While Not EOF do Begin
ReadLn(Input,CurrLine);
If LastLine<>CurrLine Then WriteLn(Output,CurrLine);
LastLine:=CurrLine;
End;
End;
END.