Unable to grep:
Able to grep:
Unable to grep:
Able to grep:
^ and * have special meanings to grep. Escape them like \^\^\^613\*"
I have rectified my post...i had used single quotes ''
^ and * still have special meanings to grep. Escape them.
^ and * have special meanings in perl regular expressions, too.
Escape them!
lol
Plus, in old shells, the '^' character is the same as a pipe:
$/bin/sh
$ who|wc -l
9
$ who^wc -l
9
$
So I would listen to Corona688! lol
Wow, I've never seen that behavior anywhere. I can only guess that shell was made for a system that didn't always have the | key
I found a reference to it here: Thompson shell - Wikipedia.
It would seem that Bourne kept it for compatibility with the Thompson shell I guess.
It's mentioned here too in the Thompson shell man page: http://www.in-ulm.de/~mascheck/bourne/v4/
search for the circumflex character '^'.
"One or more commands separated by '|' or '^' constitute a pipeline."
Look at this even older Thompson shell version, where pipe symbols were the same as redirection: http://www.in-ulm.de/~mascheck/bourne/v3/
By extending the syntax used for
redirection of I/O, a command line can specify that the
output produced by a command be passed via a pipe through
another command which acts as a filter. For example:
command >filter>
The problem is that "^^^613*" will be stored in a variable(i) like
How will the script understand when will $i contain a special character and escape that automatically
Hi.
Yes, like TTY33's -- ASR-33 Teletype - Wikipedia, the free encyclopedia -- limited character set, uppercase only, slow, noisy, etc., adapted for interactive work from other environments ... cheers, drl
For grepping use fgrep:
$ i="^^^613*"
$ echo "$i"
^^^613*
$ echo '/test/x201.cfg:reg.1.random="^^^613*"' | fgrep "$i"
/test/x201.cfg:reg.1.random="^^^613*"
A quick and dirty way to escape these special characters:
perl -pi -e "s|$(printf "%s" "$i"|sed 's/[*^]/\\&/g')|$passwd|g" "$k"