Hi,
I need to find the lines which are repeating in a file
cat file1
abcdef 23-1
abcdef 24-1
bcdeff 25-0
ttdcfg 26-0
ttdcfg 20-0
bcdef1 25-0
bcdef2 25-0
bcdef3 25-0
bcdef4 25-0
bcdef4 00-0
any help is greatly appreciated. Thanks in advance.
In need to find which one are repating.
cat my_out_file
abcdef 23-1
abcdef 24-1
ttdcfg 26-0
ttdcfg 20-0
bcdef4 25-0
bcdef4 00-0
don't quite get your meaning.
example input/output
clx
3
Like this?
$ cat x
abcdef 23-1
abcdef 24-1
bcdeff 25-0
ttdcfg 26-0
ttdcfg 20-0
bcdef1 25-0
bcdef2 25-0
bcdef3 25-0
bcdef4 25-0
bcdef4 00-0
$
$ awk '{print $1}' x |sort | uniq -d | fgrep -f - x
abcdef 23-1
abcdef 24-1
ttdcfg 26-0
ttdcfg 20-0
bcdef4 25-0
bcdef4 00-0
$
Lots of sub shells. Hope your actual file is not so huge.
Try this...
awk '$1 in a{print (a[$1]?a[$1]RS$0:$0);a[$1]="";next}{a[$1]=$0}' input_file
For only the first column
awk '$1 in a{print (a[$1]?$1RS$1:$1);a[$1]="";next}{a[$1]=$0}' input_file
HTH
--ahamed