I want to insert '.'
between every character in a given input string and then use it as an argument in a pipe
I am doing one of the following:
tail -f file.txt | grep -a 'R.e.s.u.l.t.'
tail -f file.txt | awk '/R.e.s.u.l.t./'
How can I just type 'Result'
and pass it as the regex argument to grep
when
receiving input from a buffer created by tail -f
by using additional bash
default functions
The awk version:
This echoes the word
Result
as input tosed
(consider a here-string instead), which replaces each character with itself followed by a.
, and then the output is used as the search expression forgrep
. The-e
protects you from mishaps if you want to search for-argument
with the dots, for example. If the string is in a variable, then you'd use double quotes around that, too: