![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| substring ?? | varungupta | Shell Programming and Scripting | 7 | 10-01-2007 09:18 AM |
| substring | panknil | Shell Programming and Scripting | 4 | 10-01-2007 08:12 AM |
| substring | alla.kishore | UNIX for Dummies Questions & Answers | 8 | 01-09-2007 02:57 AM |
| swap space / paging space | aaronh | AIX | 2 | 05-19-2004 10:06 AM |
| pageing space vs swap space | VeroL | UNIX for Dummies Questions & Answers | 1 | 01-22-2004 11:54 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Substring not working if more than 1 space
I have a string which is something like this..
abcd efghijkl when I use this using substring() function 2 spaces are bein considered as one starngely. Is there any thing I am doing wroing the input file maintest has the string specified and the code is below while read lines do echo $lines | awk '{print substr($0,4,3)}' done < maintest the output is d e where as it should be 'd ' d followed by 2 blank spaces. Please suggest thanks |
|
||||
|
Your code works if there is more than one space. Maybe the problem is that you're testing with echo and if you do echo word1<space><space>word2 the output will be "word1<space>word2". If you want echo to output more than one space use ", echo "word1<space><space>word2".
|
|
||||
|
No problem. That happened because despite how many spaces you type, the number of arguments is the same and echo only cares about arguments (which are then separated by a single space).
Code:
echo one two Code:
echo "one two" Glad I could help. |
| Sponsored Links | ||
|
|