SuaSwe
October 9th, 2010, 12:37 AM
Hi all,
I'm having some problems with one section of a script I'm writing. The code I have currently looks as follows:
cat test | uniq -c | awk '{ if ($1 >1) print $1,$2 }' > test.output
... where 'test' is a file containing the following info:
item1
item2
item3
item4
item5
item5
item6
item7
As it stands, the script outputs the count and name(s) of any repeated items in 'test' regardless of whether there is a repeat count or not - so if there isn't, I just get a blank file. What I want is for the script to output the count and name into 'test.output' only if an item is repeated in 'test'. Could anyone tip me off on how to do this?
Cheers!
I'm having some problems with one section of a script I'm writing. The code I have currently looks as follows:
cat test | uniq -c | awk '{ if ($1 >1) print $1,$2 }' > test.output
... where 'test' is a file containing the following info:
item1
item2
item3
item4
item5
item5
item6
item7
As it stands, the script outputs the count and name(s) of any repeated items in 'test' regardless of whether there is a repeat count or not - so if there isn't, I just get a blank file. What I want is for the script to output the count and name into 'test.output' only if an item is repeated in 'test'. Could anyone tip me off on how to do this?
Cheers!