Quote:
Originally Posted by Pinkk
but it gives the No such file or directory on these:
word=$("$lala"|grep "$2" | wc -w)
lines=$("$lala" | grep "$2" | wc -l)
|
You didn't specify any input file.
This shows lines containing "raven" in the famous
Edgar Allen Poe poem...
Note the
< /home/daniel/Desktop/LQfiles/raven.txt identifies the input file.
Code:
daniel@daniel-desktop:~$ grep raven < /home/daniel/Desktop/LQfiles/raven.txt
In there stepped a stately raven of the saintly days of yore.
'Though thy crest be shorn and shaven, thou,' I said, 'art sure no craven.
Ghastly grim and ancient raven wandering from the nightly shore -
Quoth the raven, 'Nevermore.'
But the raven, sitting lonely on the placid bust, spoke only,
But the raven still beguiling all my sad soul into smiling,
Quoth the raven, 'Nevermore.'
Quoth the raven, 'Nevermore.'
Quoth the raven, 'Nevermore.'
Quoth the raven, 'Nevermore.'
And the raven, never flitting, still is sitting, still is sitting
Now let's go one step farther.
This counts those lines.
Code:
daniel@daniel-desktop:~$ grep raven < /home/daniel/Desktop/LQfiles/raven.txt |wc -l
11
Continuing this example ...
This stuffs the numeric value 11 into the variable TT.
Code:
daniel@daniel-desktop:~$ TT=$(grep raven < /home/daniel/Desktop/LQfiles/raven.txt |wc -l)
... and this displays the contents of variable TT.
Code:
daniel@daniel-desktop:~$ echo $TT
11
Daniel B. Martin