line containig spaces


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers line containig spaces
# 1  
Old 09-22-2006
line containig spaces

hi i have file having following contain

2~%%~2~%%~7~%%~1~%%~none~%%~XYZ_MOV_HDR_REC~%%~1~%%~17_REC_ID == "H"
2~%%~2~%%~8~%%~2~%%~none~%%~XYZ_MOV_EXCL~%%~2~%%~20_UPC<=99999999

see the last column of first line having spaces i have a script

cat rec_iden_file
for i_line in `cat rec_iden_file`
do
echo $i_line
done

here i am printing each line of file
but as first line has a space in last column output of script is

-------------------------------
2~%%~2~%%~7~%%~1~%%~none~%%~XYZ_MOV_HDR_REC~%%~1~%%~17_REC_ID == "H"
2~%%~2~%%~8~%%~2~%%~none~%%~XYZ_MOV_EXCL~%%~2~%%~20_UPC<=99999999
2~%%~2~%%~7~%%~1~%%~none~%%~XYZ_MOV_HDR_REC~%%~1~%%~17_REC_ID
==
"H"
2~%%~2~%%~8~%%~2~%%~none~%%~XYZ_MOV_EXCL~%%~2~%%~20_UPC<=99999999
-------------------------
see the first line treated as 3 lines...

any pointers why this is happening and solution for it

thanks
mahabunta
# 2  
Old 09-22-2006
By default IFS is space. If you want to print the whole line then set IFS to some character that is not in the file

or use this

Code:
cat rec_iden_file
while read i_line
do
echo $i_line
done < rec_iden_file

# 3  
Old 09-22-2006
thanks anubh while loop worked... Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replacing valuses containig space and special characters

**Extremely sorry for the typos in heading Old:CAST ('${DEFAULT_HIGH_DATE}' AS DATE FORMAT 'YYYY-MM-DD') New :CAST(CAST('${G_DEFAULT_HIGH_DATE}' AS DATE FORMAT 'MM-DD-YYYY') as DATE FORMAT 'YYYY-MM-DD') Need to change old format as new format cat file1 CAST ('${DEFAULT_HIGH_DATE}' AS... (1 Reply)
Discussion started by: 100bees
1 Replies

2. Shell Programming and Scripting

How to remove spaces on a line?

Hi, suppose I have the following data: albert music=top40 age=20 bob music=punk rock age=25 candy music=r n b age=22 dave music=mozart or bach only age=30 I want to extract and manipulate the music column but it's got spaces in it. How can I substitute the space with an underscore... (2 Replies)
Discussion started by: almonds
2 Replies

3. UNIX for Advanced & Expert Users

Need spaces in line after few charcacters

This is my headerHJKLName00014200012000000600424618201after head 201 I am looking for 382 space.total wc will be 421 then can you tell me how can I accomplish this we are performing some more actions in script, which is working fine..but this part I need help.please suggest where changes need... (9 Replies)
Discussion started by: mirwasim
9 Replies

4. Shell Programming and Scripting

Reading complete line after spaces

Hi, I am reading data from a variable which has spaces in it. I want to get the data after first space, i.e. if my data line is "My Name is Ashish...", I want the data returned as "Name is Ashish". I am using #!/bin/sh shell. Please help me with the code to read the complete data after first... (8 Replies)
Discussion started by: gupt_ash
8 Replies

5. Shell Programming and Scripting

Read file line spaces

I have a script which read a file it does while read -r line, then i echo line out echo "$line" Problem is the echo does not echo space and tabs at the end of each line. How do i get the end of line space as well (6 Replies)
Discussion started by: kelseyh
6 Replies

6. Shell Programming and Scripting

Removing spaces in a line

Hi All, I have a line like this " field1;field2;field3 " (single space after and before double quotes). Now i have to remove these single space . Kindly help me. Thanks in advance (2 Replies)
Discussion started by: krishna_gnv
2 Replies

7. UNIX for Dummies Questions & Answers

how to append spaces(say 10 spaces) at the end of each line based on the length of th

Hi, I have a problem where I need to append few spaces(say 10 spaces) for each line in a file whose length is say(100 chars) and others leave as it is. I tried to find the length of each line and then if the length is say 100 chars then tried to write those lines into another file and use a sed... (17 Replies)
Discussion started by: prathima
17 Replies

8. Shell Programming and Scripting

remove trailing spaces from a line

I want to remove the trailing spaces from any line of file. line ending does not follow any pattern. plz help (3 Replies)
Discussion started by: vikas_kesarwani
3 Replies

9. UNIX for Dummies Questions & Answers

Reading a line including spaces

Hi All, I have a script that reads a file and echo it back to std out. Test.txt 1aaaaaaaaaaa . The script is ReadLine.sh #!/bin/ksh cat $1 | while read file do echo $file done I invoke the script as ReadLine.sh Test.txt The output that I get is (1 Reply)
Discussion started by: aksarben
1 Replies

10. Shell Programming and Scripting

adding spaces to a line

Is there any command to add spaces to a lline....say i need 50 spaces between the data like "aaabbbccc dddeeefff" or may be like this "aaaabbbbbbcccccdddddeeeffff " your help is appreciated. (4 Replies)
Discussion started by: mgirinath
4 Replies
Login or Register to Ask a Question