![]() |
|
|
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 |
| Cannot read a file with read(fd, buffer, buffersize) function | naranja18she | High Level Programming | 3 | 06-12-2009 02:39 PM |
| Can I use read to read content of a variable | nmalencia | Shell Programming and Scripting | 9 | 03-26-2009 06:58 AM |
| read is not pausing to read | davegerdt | Shell Programming and Scripting | 3 | 04-07-2008 11:20 AM |
| ls while read loop - internal read picking up wrong input | dkieran | Shell Programming and Scripting | 2 | 05-14-2007 04:02 PM |
| read line and read next | ariuscy | UNIX for Dummies Questions & Answers | 7 | 09-21-2005 08:04 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
read and IFS
Hi,
This is out of curiosity: I wanted to extract year, month and date from a variable, and thought that combining read and IFS would help, but this doesn't work: echo "2010 10 12" | read y m d I could extract the parts of the date when separated by a -, and setting IFS in a subshell: r=$(echo '2010-10-12' |(IFS='-'; read y m d; echo $y $m $d)) Any explanation why the first doesn't work? Thanks Raphaël |
|
||||
|
In ksh: Code:
echo "2010 10 12" | read y m d In Bash (and newer ksh's): Code:
read y m d <<< "2010 10 12" Using IFS: Code:
echo '2010-10-12' | IFS='-' read y m d echo $y $m $d 2010 10 12 IFS='-' read y m d <<< "2010-10-12" echo $y $m $d 2010 10 12 |
![]() |
| Bookmarks |
| Tags |
| bash, ifs |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|