Re: printf as stdin... another solution?
From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 11/29/05
- Next message: Harry: "Re: print one occurance for duplicate entries"
- Previous message: Dan Mercer: "Re: ksh under Cygwin"
- In reply to: serrand: "printf as stdin... another solution?"
- Next in thread: Michael Tosch: "Re: printf as stdin... another solution?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 ***
- Next message: Harry: "Re: print one occurance for duplicate entries"
- Previous message: Dan Mercer: "Re: ksh under Cygwin"
- In reply to: serrand: "printf as stdin... another solution?"
- Next in thread: Michael Tosch: "Re: printf as stdin... another solution?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|