need help in shell script to grep the space

one of my shell script display output in below format

file11    2
file21    3
file31    2
file42    3

first column is    --  FileName,
second  column is - its Count

now  I want to display from above,  only rows which have the file count= 3

means .. from second column which has the count=3, then only  display that row.
when I tried simply to grep for 3, then some file names include digits 3 within, having count different than required, also shown in output.

please help
mac_gAdmin - Oracle Fusion Middleware suiteAsked:
Who is Participating?
woolmilkporcConnect With a Mentor Commented:
Glad I could help!
woolmilkporcConnect With a Mentor Commented:
Better use awk: | awk '+$2 == 3'

You could grep for " 3" (space 3), but this will also show counts like "31". To avoid this you could grep for " 3$" (not " 3 ", because there is probably no space after the number!).
If there is sometimes a space following the number and sometimes not you can grep for " 3[ ]*$" (a space, "3", no space or any count of spaces, line end).

But the awk above will already take all this into account.
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
Thanks for your reply..

I am not getting anything  when applied below command,.....any futher customization required ?

sh | awk '+$2 == 3'
7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

This is strange. Did you really post the original output?

Could it be that you're under Solaris? In this case please use "nawk"!
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
apologies my mistake  ..

I got the required one from your advice ..

thanks lot for your help...

God Bless you
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
I need one more small help in this regard

as of now I am getting required output want I needed

now I want to move files which has count 3  to some temp-directory.

count-3 means .. single file will be generated with three different extention.

for example : menu.ext1 , menu.ext2 & menu.ex3  

I want to move  all the above menu* three file to temp dir.

how to add this step in the same script.
mac_gAdmin - Oracle Fusion Middleware suiteAuthor Commented:
coming again with all details from scratch difficult.
please allow this thread  to complete ..
as it is  about to finish..

Thanks  for your support
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.