Blank characters between Datas


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Blank characters between Datas
# 1  
Old 07-25-2003
Blank characters between Datas

Hello,

I read a file whose in lines are datas and between thses datas there is blank characters (10, 12 or 5 or 1 .......)

So when i use the command while read line in the script(see under) there is also only one character between the datas and the others blank characters are not here.

exec <$IN_DIR/${filename}

while read line ; do
echo $line
if [ $(echo ${#line}) -gt 157 ] ; then
exec 2>$IN_DIR/${filename}.$(echo $line | cut -c,158-160)
fi
echo $line>&2
done

So here is an example with the original datas with all the blank characters

5712900014 00001000 CHF00000003020720030000900009+000000149935+000000147782+000000000150+000000001980+00000000002301D09


This is the example when i read with :while read line

5712900014 00001000 CHF00000003020720030000900009+000000149935+000000147782+000000000150+000000001980+00000000002301D09


Perhaps there is an option who take the original datas and put it in the line (while read line...)

Has anyone a idea.. Thanks a lot....
# 2  
Old 07-25-2003
Enclose $line in quotes:
echo "$line"

And is
$(echo ${#line})
really what you meant to do? If $line is 10 characters long, you're going to end up with the variable $10, which will give an error. Just use the one part to return the length of the line:
${#line}
# 3  
Old 07-25-2003
Quote:
Originally posted by oombera
And is
$(echo ${#line})
really what you meant to do? If $line is 10 characters long, you're going to end up with the variable $10, which will give an error. Just use the one part to return the length of the line:
${#line}
In ksh, $(echo ${#line}) is close to `echo ${#line}` so the statement:
if [ $(echo ${#line}) -gt 157 ] ; then
is perfectly valid, although it's a bit like walking around the world to get across the street. I agree that a sensible approach might be:
if [ ${#line} -gt 157 ] ; then
# 4  
Old 07-25-2003
Blank Characters between Datas in a file

Hello,

Thanks for your answers.

So I find if a put in my script the IFS= , it take the line so that are in the original file.

It's work good..

So have a lot of thanks ... Bye...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find out the weird blank characters?

I have a text file downloaded from the web, I want to count the unique words used in the file, and a person's speaking length during conversation by counting the words between the opening and closing quotation marks which differ from the standard ASCII code. Also I found out the file contains some... (2 Replies)
Discussion started by: yifangt
2 Replies

2. Shell Programming and Scripting

Format column datas

I have some data like this: 4258092 TRXCODE a 19 CARDNBR a 10 PINFLAG a 6 FUISSUER a 12 PRODUCT a 24 STATE n 1 I want out put this format: <?xml version="1.0" encoding="GB2312"?> <convGrp> <grpid>4258092</grpid> <script> <!]> ... (4 Replies)
Discussion started by: hhdzhu
4 Replies

3. Shell Programming and Scripting

To check Blank Lines, Blank Records and Junk Characters in a File

Hi All Need Help I have a file with the below format (ABC.TXT) : ®¿¿ABCDHEJJSJJ|XCBJSKK01|M|7348974982790 HDFLJDKJSKJ|KJALKSD02|M|7378439274898 KJHSAJKHHJJ|LJDSAJKK03|F|9898982039999 (cont......) I need to write a script where it will check for : blank lines (between rows,before... (6 Replies)
Discussion started by: chatwithsaurav
6 Replies

4. Shell Programming and Scripting

Removing blank/white spaces and special characters

Hello All , 1. I am trying to do a task where I need to remove Blank spaces from my file , I am usingawk '{$1=$1}{print}' file>file1Input :- ;05/12/1990 ;31/03/2014 ; Output:- ;05/12/1990 ;31/03/2014 ;This command is not removing all spaces from... (6 Replies)
Discussion started by: himanshu sood
6 Replies

5. Shell Programming and Scripting

Removing one or more blank characters from beginning of a line

Hi, I was trying to remove the blank from beginning of a line. when I try: sed 's/^ +//' filename it does not work but when I try sed 's/^ *//' filename it works But I think the first command should have also replaced any line with one or more blanks. Kindly help me in understanding... (5 Replies)
Discussion started by: babom
5 Replies

6. UNIX for Dummies Questions & Answers

Comparing datas in two excel file

Hi All, i have two excel sheets with same column name as below col1 col2 col3 ---- ---- ----- 1 121 156 24 456 788 45 444 777 765 32 77 col1 col2 col3 ---- ---- ----- 24 456 ... (1 Reply)
Discussion started by: arunmanas
1 Replies

7. Shell Programming and Scripting

Print separated datas

Hi People !! I need your help. I have a a txt file "example" with it datas. 11:35 10/12/2003 10.10.10.1 God.com 5 country Responsable of ASN 11:37 12/12/2003 10.10.10.1 FATHER.COM 5 country Responsable of ASN 11:40 14/12/2003 10.10.10.3 www.mother 6... (6 Replies)
Discussion started by: ras
6 Replies

8. Shell Programming and Scripting

arranging datas if input file is not having also...!!

hi, my input file is containg uid, eriMaster ,eriResign, ericontry, dept. some of the uid are not having all info. out put should include all info irrespctive of datas of input file if any one data is missing, then it has to print Null or zero..then continue with the existing one. here... (0 Replies)
Discussion started by: hegdeshashi
0 Replies

9. Shell Programming and Scripting

Deleting the blank line in a file and counting the characters....

Hi, I am trying to do two things in my script. I will really appreciate any help in this regards. Is there a way to delete a last line from a pipe delimited flat file if the last line is blank. If the line is not blank then do nothing..... Is there a way to count a word that are starting... (4 Replies)
Discussion started by: rkumar28
4 Replies

10. Shell Programming and Scripting

select datas from an input file

I have a file containing a list of references and I want to run a script that will make the same action for each reference. The input file changes every hour, it's why I want to use a script that can read in a file, record by record, and run a specific action for the reference readed. Thanks... (1 Reply)
Discussion started by: dde
1 Replies
Login or Register to Ask a Question