Reputation: 577
Can anyone be of help why this is giving me errors and not working at my ~/.bashrc
.
greatly appreciated:
alias ferr='grep ^ \'ERRROR\' '
trying to get ferr to find all lines that starts with ^ ERROR
(note: space between ^
and ERRROR
).
I tried this too but didn't seem to work:
ferr() {grep ^' ERROR' "$@"}
this is probably one of those of course that is the problem moments.
Upvotes: 1
Views: 58
Reputation: 2524
use alias ferr='grep -E "^ERROR"'
then to search all lines starting with ERROR, just use [bash]$ ferr <filename>
.
To search with a different string replace what's inside "
Upvotes: 0
Reputation: 328574
There are several problems. Inside of single ticks \
has no effect. So the shell sees: grep ^ \
followed by ERROR' '
. That means the shell only sees three of the four ticks and it wonders where the last one went.
Next, I don't think that ^
is a valid argument to grep
. Try "^ ERROR"
(and make sure you get the number of R
s right, too).
And if you want to match something at the start of a line, use
alias ferr="egrep '^pattern'"
where pattern is what you look for. This becomes more complex if the pattern really contains ^
. For sake of simplicity, I suggest to search:
alias ferr="egrep '^. ERROR'"
i.e. search for any line that starts with anything, followed by space, followed by the word ERROR
Upvotes: 1
Reputation: 6258
Try:
alias ferr="grep ^ERRROR"
To include the space before ERROR try:
alias ferr="grep \"^ ERRROR\""
Upvotes: 0