Search code examples
linuxshellksh

Filter unique row with positional file and fixed position of the key


I work with with KornShell Script.

I have a positional file formatted like this:

XXXXXXXXXXXYYYYYYYYYYYYYYYYYYYYY

X is my key 11 length and I want to filter this file with unique key constraint.

X it is an String Type which could have values like that:

FJUYHGRESJFYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
ZNXKDDYHDNKYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

I have test this command :

cat Stack.txt | uniq -D -s 11 > Result.txt

Solution

  • Try this command :

    cat Stack.txt | uniq -w 11 > Result.txt