* Quoting that expression as an tcsh-alias ?

* Quoting that expression as an tcsh-alias ?

Post by Steffen Schwig » Sun, 15 Oct 1995 04:00:00



Hi!

Currently I'm using a one-line-script "summe" with that content:

  echo `gawk 'BEGIN {printf "0"} ; {printf "+%d", $1}'` | bc

to get a sum of a lot of numbers by piping the numbers through this line.
(e.g.  df | awk '{print $3}' | summe )

Now I tried to define this line as an tcsh-alias, but I wasn't successful in
quoting this line.
If you can do that, please mail/post it.

BTW, do you know, why this simpler line doesn't print an output:

  gawk 'BEGIN {printf "0"} ; {printf "+%d", $1}' | bc

I have to use it with echo.

(Greeti+Tha)nX
Steffen
--
Steffen Schwigon

Signature fault (.plan dumped)

 
 
 

* Quoting that expression as an tcsh-alias ?

Post by Gora Mohan » Wed, 18 Oct 1995 04:00:00



Quote:>Hi!
>Currently I'm using a one-line-script "summe" with that content:
>  echo `gawk 'BEGIN {printf "0"} ; {printf "+%d", $1}'` | bc
>to get a sum of a lot of numbers by piping the numbers through this line.
>(e.g.  df | awk '{print $3}' | summe )
>Now I tried to define this line as an tcsh-alias, but I wasn't successful in
>quoting this line.

In tcsh, try the following:

 % set backslash_quote
 % alias summe 'echo `gawk \'BEGIN {printf "0"} {printf "+%d", $1}\'` | bc'

Note that the single quotes for the gawk statement are escaped with a
backslash, so that they are not confused with the single quotes for the alias
command. The 'set backslash_quote' statement instructs tcsh to parse the line
in this manner. I think the old csh did not have this feature, so that it has
to be specifically enabled in tcsh.
      By the way, wouldn't the following be simpler:

 gawk '{ sum += $1 } END{ print sum }'

Quote:>BTW, do you know, why this simpler line doesn't print an output:
>  gawk 'BEGIN {printf "0"} ; {printf "+%d", $1}' | bc
>I have to use it with echo.

Because you haven't printed out a newline, 'bc' is not seeing the end of the
line. Try,

   gawk 'BEGIN {printf "0"} ; {printf "+%d", $1} END{ printf"\n" }' | bc

                                           Regards,
                                               Gora

 
 
 

1. REGULAR EXPRESSIONS; PERL/AWK/SED; SINGLE QUOTES/DOUBLE QUOTES

Hi,

I am trying to look for the string

.uk,|/|end-of-string

this regular expression can be constructed as follows:

'\.uk,|/|$'

Now, suppose I stick the text uk into a variable called $suffix.
I can no longer use single quotes, because I destroy the meaning of
$suffix. If I use double quotes, though, then i Destroy the special
meaning of the metacharacter $.

"\.$suffix,|/|$"

Help!

Never mind,

I wound up using "\.$suffix"',|/|$', but this problem is so persistent
and pervasive in awk, csh, sed, and even perl that I wonder if there
are better-documented solutions.

Also, what is csh's equivalent of the \b,\w,\s constructs in perl?

Sent via Deja.com http://www.deja.com/
Before you buy.

2. POP-2 or POP-3 for HP-UX?

3. Multple, or nested quotes ("') in tcsh alias

4. Site for application binaries for linux on powermac?

5. Creating tcsh or csh alias containing both single-quotes and dollar

6. LILO: Booting Linux partition residing on a secondary drive

7. tcsh/csh expression alias redone for bash

8. Problems using the Gimp program in Redhat 6.2

9. how to explain the expression in single quotes?

10. ksh - regular expressions and quoting problem in command

11. quoting and regular expressions

12. Quoting / ksh / AIX / command substitution / regular expression = one script problem ...

13. tcsh xterm title bar quoting