BASH - how to press ENTER
I'm searching for a word in a text file with the command 'grep' and using 'grep -c' to print the number of matches on the screen. Afterwards I want to use a 'read' command, so that I can get the printed number. That is what I wrote in a script:
grep -c -i -w "channel" <main.cpp
Right now I have two problems:
1) the 'grep -c' command writes the number of matches and right afterwards it prints the number of matches (as expected), but it also gives an ENTER (as I didn't expect), even before the command 'read' is activated.
2) so the command 'read' doesn't let my script run to the end, because it stays waiting, so that something is writen and another ENTER is given.
Does somebody has an idea how to solve this?