08 Oct 2013 @ 10:30 PM 

Hi guys,

Super short one today.

I had the following issue today : getting the stdin piped to a bash function.

I tried the following :

mycoolfunction () {

echo “This is what I got : ${1}”

}

Does not work :

echo “Hello!” | mycoolfunction

This is what I got :

 

As the pipe sends to stdio, the correct way to do it is :

mycoolfunction () {

read Whatever

echo “This is what I got: ${Whatever}”

unset Whatever

}

Results :

echo “Hello!” | mycoolfunction

This is what I got: Hello!

As simple as that…

Posted By: Dimi
Last Edit: 08 Oct 2013 @ 10:50 AM

EmailPermalink
Tags
Categories: Uncategorized


 

Responses to this post » (None)

 
Post a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

 


 Last 50 Posts
Change Theme...
  • Users » 66
  • Posts/Pages » 25
  • Comments » 4
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight