Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

grep usage failure

1 view
Skip to first unread message

Ronald J Marchand

unread,
Mar 28, 2001, 10:56:50 AM3/28/01
to
From the /usr/include/sys directory I type the following, where the
keystrokes between the "" are <tab key>1<tab key> and I get
$ grep " 1 " errno.h
#define EPERM 1 /* Not owner */

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


Jean-Pierre Radley

unread,
Mar 28, 2001, 11:20:02 AM3/28/01
to ScoMisc [c.u.s.m]
Ronald J Marchand propounded (on Wed, Mar 28, 2001 at 03:56:50PM +0000):

A regular expression does not interpret \t as anything but t. It isn't
seen as a TAB.

--
JP

J. L. Schilling

unread,
Mar 28, 2001, 11:41:14 AM3/28/01
to
Ronald J Marchand <rjm...@home.com> wrote:
: From the /usr/include/sys directory I type the following, where the

: keystrokes between the "" are <tab key>1<tab key> and I get
: $ grep " 1 " errno.h
: #define EPERM 1 /* Not owner */

: 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

Ronald J Marchand

unread,
Mar 28, 2001, 12:56:05 PM3/28/01
to

Jean-Pierre Radley <j...@jpr.com> wrote in message
news:2001032811...@jpradley.jpr.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


Jean-Pierre Radley

unread,
Mar 28, 2001, 1:44:16 PM3/28/01
to ScoMisc [c.u.s.m]
Ronald J Marchand propounded (on Wed, Mar 28, 2001 at 05:56:05PM +0000):

| >
| > A regular expression does not interpret \t as anything but t. It isn't
| > seen as a TAB.
|
| 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???

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

John DuBois

unread,
Mar 28, 2001, 11:33:58 PM3/28/01
to

In article <VApw6.510583$ge4.18...@news2.rdc2.tx.home.com>,

Ronald J Marchand <rjm...@home.com> wrote:
+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???

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

Ronald J Marchand

unread,
Mar 29, 2001, 10:30:07 AM3/29/01
to

John DuBois <jo...@sco.COM> wrote in message
news:99udvm$4nc$1...@hobbes.sco.com...

>
> In article <VApw6.510583$ge4.18...@news2.rdc2.tx.home.com>,
> Ronald J Marchand <rjm...@home.com> wrote:
> +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???
>
> 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

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.

0 new messages