Re: printf as stdin... another solution?

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 11/29/05


Date: Mon, 28 Nov 2005 23:51:54 -0500

In article <438b8e0e$0$6673$8fcfb975@news.wanadoo.fr>,
 serrand <xavier.serrand@free.fr> wrote:

> Hello all,
>
> I would like to affect a variable with a command which input is stdin...
> ok simplissim...
>
> myvar=`ls * | grep 'mypattern' | wc -l`
>
> now i want to do the same... but from a loop
>
> for i in commande1; do ...using $i...; myvar=`printf "%s" "$i" | wc -l`
> ; done
>
> is printf or some equivalent (like find ... -print) the only way to
> retrieve values of an expression in order to give it as input to another
> command?

Yes, you have to use something like printf or echo, if the command
expects its input on stdin rather than as a command-line argument.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


Relevant Pages

  • Re: noobish dsadd computer script question
    ... I do not understand how the Active Directory Command ... Line Interface accepts information from a file using STDIN. ... Judging from the text in the book and the text in the DSADD help file, ...
    (microsoft.public.windows.server.scripting)
  • RE: What is the source of my input, file or STDIN?
    ... I could have been more explicit in my question to have stated that ... command line or if not invoked as the recipient of piped output. ... no command line args - switching to STDIN ... If input stream is not coming from STDIN, but a file, how can one ...
    (perl.beginners)
  • Re: Editable input from the console windows
    ... stdin, stdout, and stderror in relationship to pipe commands. ... I understand the fundamentals behind redirection. ... The exec command adds to the confusion as well. ... I learning the syntax and build upon a previously working script. ...
    (comp.unix.shell)
  • Re: noobish dsadd computer script question
    ... I do not understand how the Active Directory Command ... Line Interface accepts information from a file using STDIN. ... Judging from the text in the book and the text in the DSADD help file, ... as your file separates the names with carriage ...
    (microsoft.public.windows.server.scripting)
  • Re: noobish dsadd computer script question
    ... I do not understand how the Active Directory Command ... Line Interface accepts information from a file using STDIN. ... Judging from the text in the book and the text in the DSADD help file, ... as your file separates the names with carriage ...
    (microsoft.public.windows.server.scripting)