Filtering Data

Hi All,

I have the below input and expected ouput. I need a code which can scan through this input file and if the number in column1 is more than 1 , it will print out the whole line, else it will output "No Re-occurrence". Can anybody help ?

Input:

1 vvvvv 20 7 7 23 0 64
6 zzzzzz 11 5 5 13 0 1
1 uuuuu 17 0 0 24 0 146
5 qqqqq 7 3 3 11 0 199
1 ggggg 11 5 5 13 0 13
1 yyyyy 13 7 7 31 0 252

Expected Output:

6 zzzzzz 11 5 5 13 0 1
5 qqqqq 7 3 3 11 0 199

Try...

awk '{if ($1>1) print $0; else print "No Re-occurrence"}' file1
awk '$1>1?1:$0="No occurence"' file

output:

# ./test.sh
No occurence
6 zzzzzz 11 5 5 13 0 1
No occurence
5 qqqqq 7 3 3 11 0 199
No occurence
No occurence

by the way, try to put in some effort next time.

Hi Ghostdog,

I only want the the below to surface column1 more than 1.

6 zzzzzz 11 5 5 13 0 1
5 qqqqq 7 3 3 11 0 199

If column1 does not contain 1 then output "No occurence"

eg
Input:
1 vvvvv 20 7 7 23 0 64
1 uuuuu 17 0 0 24 0 146
1 ggggg 11 5 5 13 0 13
1 yyyyy 13 7 7 31 0 252

Output:
No occurrence

If you do not want the lines with first column =1 then just remove the else part of the syntaxes recomended above.

Thanks
namish

Try this :

awk '$1>1 { print; c++ } END { if (c==0) print "No occurrence" }' file

Jean-Pierre.

Thnks Jean it works!!

However, how can i modify the code such that when 2 or more terms are repeated consecutively, it will output the the repeating term, else echo "No consecutive repeating term ?

Input:
vvvvv 20 7 7 23 0 64
uuuuu 17 0 0 24 0 146
uuuuu 17 0 0 24 0 146
uuuuu 17 0 0 24 0 146
ggggg 11 5 5 13 0 13
yyyyy 13 7 7 31 0 252
ggggg 11 5 5 13 0 13

Expected Output:
Consecutive Repeating term = uuuuu 17 0 0 24 0 146

Can any experts give me some advice on this ?