![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to append spaces(say 10 spaces) at the end of each line based on the length of th | prathima | UNIX for Dummies Questions & Answers | 2 | 04-29-2008 02:43 PM |
| ksh - read file with leading spaces | momi | Shell Programming and Scripting | 2 | 03-17-2008 12:02 PM |
| adding spaces to a line | mgirinath | Shell Programming and Scripting | 4 | 03-23-2007 09:38 AM |
| Read files including spaces | kumariak | Shell Programming and Scripting | 4 | 06-08-2005 04:36 AM |
| Keep spaces with read command | azmathshaikh | Shell Programming and Scripting | 3 | 03-22-2005 01:17 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to read a line when it starts with spaces
Hi ,
I use read command to get the input text, When i try to get the line starting with spaces or ending with spaces it automatically truncates the spaces and displays the remaining content. Code i tried (UserInput.sh): #!/bin/bash echo -n "Enter some text > " read text echo "You entered: $text" When i give this as input " Hello How " It displays "You entered: Hello How" , It has truncated the spaces. Is there any way to get Input along with spaces ? Thank U, Prakash C. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
#!/bin/ksh print "Enter something" IFS= read var IFS=" " print "$var" |
|
#3
|
||||
|
||||
|
bash
|
|
#4
|
|||
|
|||
|
Thank u for replying
It has worked for me.
Thanks, |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|