![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AIX 5.3 - There is no process to read data written to a pipe | vigsgb | UNIX for Advanced & Expert Users | 6 | 05-22-2009 05:59 AM |
| pipe read and write with many forked children | steveneliuk | High Level Programming | 5 | 05-23-2007 07:03 AM |
| Problem in read() from a pipe | JDS | High Level Programming | 2 | 10-13-2006 11:19 AM |
| Pipe Problem | vivivo2000 | High Level Programming | 2 | 01-11-2006 04:43 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
read after pipe problem OSX10.4
I use read often in scripts to filter the right part into a variable like:
$ print "abc cde efg" | read k l ; print "k=$k, l=$l" k=, l= This works on linux and unix versions I work with. On OSX 10.4 this doesn't work. I found a workaround but would like to know why the original line fails. And I don't like the $ print "abc cde efg" |& read -p k l ; print "k=$k, l=$l" [1] 11299 k=abc, l=cde efg Greetings, William |
|
||||
|
Thanks for the replies, Perderabo and R2007.
Perderabo, what is strange is that when I start a different terminal, or a different shell, they all behave the same. I tried bash, tcsh, csh and sh. I expect it has to do with the OSX darwin or BSD system. Also commands like ls and tar are different. It took me some time to get colors enabled and app-defaults installed right for keybord shortcuts. The csh results: $ csh [d213-102-60-49:~] relyveld% echo "abc cde efg" | read k l ; echo "k=$k, l=$l" csh: k: Undefined variable. Finaly, I tried zsh and this one works! But I don't know zsh and all my scripts are ksh based.. zsh: d213-102-60-49% zsh which read read: shell built-in command d213-102-60-49% exit ksh: $ which read /usr/bin/read $ zsh d213-102-60-49% echo "abc cde efg" | read k l ; echo "k=$k, l=$l" k=abc, l=cde efg Test result (ksh): $ print "abc cde efg" | { read k l ; print "k=$k, l=$l" ; } k=, l= Greetings, William. |
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|