Bash loop command until file contains n duplicate entries (lines)
Posted
by Andrew
on Stack Overflow
See other posts from Stack Overflow
or by Andrew
Published on 2010-03-19T00:46:52Z
Indexed on
2010/03/19
0:51 UTC
Read the original article
Hit count: 247
bash
|duplicates
Hello, I'm writing a script and I need to create a loop that will execute same commands until file does contain a specified number of duplicate entries. For example, with each loop I will echo random string to file results
. And I want loop to stop when there are 10 lines of of the same string.
I thought of something like
while [ `some command here (maybe using uniq)` -lt 10 ]
do
command1
command2
command3
done
Do you have any idea how can this problem be solved? Using grep can't be done since I don't know what string I need to look for.
Thank you for your suggestions.
© Stack Overflow or respective owner