Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-09-2008, 05:08 PM   #1
Registered: Jul 2005
Posts: 33

Rep: Reputation: 15
Beginner question on using pipes

Hi, I'm trying to write a script that is going to use another program's stdout. For example if I type:

echo hello!|

I want to use the string "hello!". I tried to use $1 but it does not work. So I'm confused a little bit. I thought the output of "echo hello!" which clearly is "hello!" should have been redirected to as standard input but it didn't. What am I doing wrong here?

Thanks in advance.
Old 09-09-2008, 05:27 PM   #2
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 5,390

Rep: Reputation: 409Reputation: 409Reputation: 409Reputation: 409Reputation: 409
use read function in
while read line; do
   echo $line
Old 09-09-2008, 06:09 PM   #3
Registered: Dec 2007
Location: Charleston WV, USA
Distribution: Slackware 12.2, Arch Linux Amd64
Posts: 896

Rep: Reputation: 69
In your script you need to read from the standard input. $1 is just the first argument presented to the script at start time in the command line. It is not the standard in, it's a very different thing.
Old 09-09-2008, 06:14 PM   #4
Registered: Jul 2005
Posts: 33

Original Poster
Rep: Reputation: 15
Thank you both


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about reading/writing into a Named Pipes(FIFO) Sathya Programming 21 05-05-2008 08:39 AM
question from a beginner: install robzane Linux - Hardware 3 09-01-2006 07:14 PM
qt beginner question fakie_flip Programming 1 08-30-2005 06:10 PM
Question regarding pipes alltime Programming 3 04-15-2005 07:54 PM
Beginner question Ephack Linux - Networking 3 10-26-2001 03:40 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration