Why does my test fail ??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Why does my test fail ??
# 8  
Old 01-27-2012
oops the last file posted was dos2unixed here is the original
# 9  
Old 01-27-2012
When I open the original file in a UNIX text editor I see:

Code:
Distributeur
Alliance Vivafilm
Origine
...

Don't edit text files for UNIX in notepad. If you'd been editing them in UNIX you'd have seen those characters; they're what Notepad inserts at the beginning of Unicode text files to warn itself that they're unicode(UTF8 in this case), and that's what's messing up your comparison.

Here's an improvement on dos2unix for that, stripping out those faulty characters and windows' carriage returns at the same time:

Code:
tr -d '[\r\357\273\277]' < wingarbage.txt > actualtext.txt


Last edited by Corona688; 01-27-2012 at 05:45 PM..
This User Gave Thanks to Corona688 For This Post:
# 10  
Old 01-27-2012
try to use :
Code:
if [ "$LINE" != "$Distor" ]; then

# 11  
Old 01-27-2012
Quote:
Originally Posted by justbow
try to use :
Code:
if [ "$LINE" != "$Distor" ]; then

i did before posting...the test is OK... the problem is not there...
Quote:
Don't edit text files for UNIX in notepad. If you'd been editing them in UNIX you'd have seen those characters; they're what Notepad inserts at the beginning of Unicode text files to warn itself that they're unicode(UTF8 in this case), and that's what's messing up your comparison.
I extract those from a file i download from a website, when downloaded the file is ISO-8859-1 i use:

Code:
vim +"set bomb | set fileencoding=utf-8 | wq" $(find . -type f -name info.txt)

to change to UTF8
# 12  
Old 01-27-2012
That has done more than changing the character set seemingly -- it also put the identifier in the front.
This User Gave Thanks to Corona688 For This Post:
# 13  
Old 01-27-2012
Smilie THANKX !!!
Code:
$ ./test.sh 
Distributeur
Distributeur

123-Distributeur-123
123-Distributeur-123
Distributeur
Alliance Vivafilm

what would be the best way to change encoding w/o using vim ?

Last edited by patx; 01-27-2012 at 07:26 PM..
# 14  
Old 01-27-2012
Quote:
what would be the best way to change encoding w/o using vim ?
Sort the format out on the Microsoft platform.
Imho there is too much effort spent in the unix world sorting out Microsoft file formats.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Fail to register

After inputted all required fields in registration page, the below message is shown and cannot go on. A required field called Custom Date & Time Formats is missing or has an invalid value. (2 Replies)
Discussion started by: Unregistered
2 Replies

2. Shell Programming and Scripting

Untar fail

Hi Team, I have a file named as follows: aaa.tar.gz Now I need to verify if the untar fails, then the script has to send a mail. In order to check this condition, I need a tar.gz file which is unable to untar it. Can anyone help me to create a file which I will be able to unzip successfully... (2 Replies)
Discussion started by: kmanivan82
2 Replies

3. Shell Programming and Scripting

Prefixing test case methods with letter 'test'

Hi, I have a Python unit test cases source code file which contains more than a hundred test case methods. In that, some of the test case methods already have prefix 'test' where as some of them do not have. Now, I need to add the string 'test' (case-sensitive) as a prefix to those of the... (5 Replies)
Discussion started by: royalibrahim
5 Replies

4. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

5. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

6. Solaris

cdrom test fail

Hi I have a problem in installing solaris 9 in a ULTRA Enterprise 2 machine. The cdrom does not keep the cd in. When I put the installtion cd 1 and close the tray, I can see the led blinks three times and then the tray comes out. I borrowed a set of installtion cd s from one of my friends (they... (3 Replies)
Discussion started by: enke1234
3 Replies
Login or Register to Ask a Question