![]() |
|
|
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 |
| Problem if parameter has space in it using loop | pinnacle | Shell Programming and Scripting | 9 | 06-16-2009 05:24 AM |
| Use of For loop with Space | peter35james | UNIX for Dummies Questions & Answers | 3 | 05-28-2009 05:55 AM |
| Moving files with space, in for loop | saabir | Shell Programming and Scripting | 6 | 02-04-2009 01:30 PM |
| how to protect white space in for loop | pondlife | Shell Programming and Scripting | 6 | 07-01-2008 08:38 AM |
| Storing space delimited line in var with loop? | eltinator | Shell Programming and Scripting | 2 | 08-24-2007 02:09 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Escape space in for loop
I have a file with the following contents Code:
[root@rf4003 scripts]# more hello.txt man hello man whereru The shell script i have tries to echo the contents of the file hello.txt Code:
for i in `cat hello.txt`
do
echo $i
done
but the output i am getting is taking the space as a new line.. Code:
[root@rf4003 scripts]# ./hello.sh man hello man whereru Can anybody help me to echo the contents of the file as it should be? |
|
||||
|
As mentioned, the use of cat is redundant and cost an extra process. Have a read of Useless Use of Cat Award.
Regards |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|