1-line-puzzle: disable format for print ? 
Author Message
 1-line-puzzle: disable format for print ?

Does anyone know how to disable printf's formatting functionality, to
print a raw-string, _WITHOUT_ modifying the string.

This works:
    bash:/> echo doit | awk "{string=\"100%top\n\"; printf string; }"
    100%top

This does not work, because %s is a format specifier:
    bash:/> echo doit | awk "{string=\"100%super\n\"; printf string; }"
                                         ^ ran out for this one
 awk: cmd. line:1: (FILENAME=- FNR=1) fatal: not enough arguments to
satisfy format string `100%super'

Of cource it works, when we modify the string by escaping '%' like this
'%%' :
    bash:/> echo doit | awk "{string=\"100%%super\n\"; printf string; }"

    100%super

Thank you



Sun, 14 Dec 2003 00:30:08 GMT  
 1-line-puzzle: disable format for print ?

Quote:

> Does anyone know how to disable printf's formatting functionality, to
> print a raw-string, _WITHOUT_ modifying the string.

> This works:
>     bash:/> echo doit | awk "{string=\"100%top\n\"; printf string; }"
>     100%top

> This does not work, because %s is a format specifier:
>     bash:/> echo doit | awk "{string=\"100%super\n\"; printf string; }"
>                                          ^ ran out for this one
>  awk: cmd. line:1: (FILENAME=- FNR=1) fatal: not enough arguments to
> satisfy format string `100%super'

> Of cource it works, when we modify the string by escaping '%' like this
> '%%' :
>     bash:/> echo doit | awk "{string=\"100%%super\n\"; printf string; }"

>     100%super

echo doit | awk "{string=\"100%super\n\"; printf "%s", string; }"


Sun, 14 Dec 2003 00:34:55 GMT  
 1-line-puzzle: disable format for print ?
echo doit | awk "{string=\"100%super\n\"; printf "%s", string; }"


Sun, 14 Dec 2003 00:43:56 GMT  
 1-line-puzzle: disable format for print ?


Quote:
>Does anyone know how to disable printf's formatting functionality, to
>print a raw-string, _WITHOUT_ modifying the string.

What problem are we trying to solve?

Your question doesn't make much sense in its current form.



Sun, 14 Dec 2003 00:46:29 GMT  
 1-line-puzzle: disable format for print ?
echo doit | awk "{string=\"100%super\n\"; printf \"%s\", string; }"


Sun, 14 Dec 2003 00:49:56 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Print formatting - same line printing?

2. Formatted output - print, write without line feed

3. how disable print botn on print preview

4. SGI: Breaking a format line into two lines

5. Puzzled: Handling Changing formats

6. Search file and print line + next line?

7. Printing line by line

8. The pretty-printer, *print-lines* and per-line prefixes

9. 1-line-puzzle: output 64-bit integer

10. Print Puzzle - Can't figure it out

11. DEFSTRUCT/print-function puzzle

12. Disabling fields during in-line wditing

 

 
Powered by phpBB® Forum Software