Then I do the following:
$ a="\t"1"\t"
$ echo $a
1
$ grep "$a" errno.h
$ grep '$a' errno.h
$ grep $a errno.h
None of the above three attempts returns a hit.
Can anyone enlighten me why it fails to find the pattern???
TIA
Ron Marchand
A regular expression does not interpret \t as anything but t. It isn't
seen as a TAB.
--
JP
: Then I do the following:
: $ a="\t"1"\t"
: $ echo $a
: 1
: $ grep "$a" errno.h
: $ grep '$a' errno.h
: $ grep $a errno.h
: None of the above three attempts returns a hit.
If you do this it'll work:
$ a=" t " # tabs embedded
$ grep "$a" errno.h
#define EPERM 1 /* Not super-user */
The backslash in grep has roughly the opposite effect of what you
were trying for: it makes special characters regular, rather than
making regular characters special.
--
Jonathan Schilling SCO, Inc. j...@sco.com
Again you are correct JP, and was I under a misconception. The other
suggestion did not work. What I am trying to do is embed a typeable string
between two non printable characters. In this case, hex 093109. How can I
set variable b=hex 09 from the keyboard and in a script???
Thanks,
Ron Marchand
> --
> JP
Bearing in mind that 'echo' groks octal, not hex, here's a small
capture from my screen:
$ TAB=`echo "\011\c"`
$ echo "$TAB\c" | hd
0000 09 .
0001
$ echo "${TAB}offset"
offset
$
--
JP
If you're using 5.0.6, you have a grep that understands characters encoded in
octal:
$ grep '\00111\0011' /usr/include/sys/errno.h
^^^^^ ^^^^^ octal encoding of tab
#define EPERM 1 /* Not owner */
For this particular problem, you might take a look at
ftp://ftp.armory.com./pub/scobins/errno
$ errno 1
EPERM (1): Operation not permitted
$ errno eperm
EPERM (1): Operation not permitted
$ errno perm
EPERM (1): Operation not permitted
John
--
John DuBois jo...@sco.com KC6QKZ/AE
I wish to God these calculations had been executed by steam. - Charles Babbage
Thanks for the link and I have retrieved the binary. My issue here was a
misunderstanding of assignment of a="\t" and years of never dealing with
octal. man ascii led me to the table /usr/pub/ascii. JP's reply led to hd
and then od. and so on....
Thanks.