-1

I/m just playing around trying to hone my grep and pipe with other functions/commands. when I run grep to find a hash tag pipe it to get a count on it. The whole thing gets stuck in term like it is still looking for input when their are no more files in the directoy. how do I get it to exit 0 giving me back my prompt?

test file reads

#
hello # what is your name 

results are

userx@voided & shit >> $  grep "#" | ls -l 
total 4
-rw-r--r-- 1 userx userx 29 Sep 26 08:26 testfile
^C

userx@voided & shit >> $  grep "#" | ls -l | wc -l > /dev/null
^C
userx@voided & shit >> $  grep "#" | ls -l | wc -l 
2
^C
userx@voided & shit >> $  grep "#" | ls 
testfile
^C

it is only one file that I have added the hash tag twice within that file put it into a directory then use this to get a count . after it returns it does not exit.

So now I'm wondering why, what am I doing wrong?

closed as unclear what you're asking by Thomas Dickey, mdpc, G-Man, Anthon, Raphael Ahrens Sep 27 '16 at 8:08

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    and why are you piping output from grep to ls ? – user4556274 Sep 26 '16 at 13:56
  • that was to feed it files. that was a backwards thought now that you ask, and I think about it. – uxserx-bw Sep 26 '16 at 14:03
2

You are not giving grep any files to search. Use

$ grep "#" testfile

or

$ grep "#" *

not simply

$ grep "#"
  • therefore using just the wildcard will search everything file within a directory ... sweet. ok thanks ... – uxserx-bw Sep 26 '16 at 14:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.