Home » Infrastructure » Linux » Urgent.reading files in linux.
Urgent.reading files in linux. [message #99252] Wed, 29 December 2004 01:17 Go to next message
Samyak
Messages: 10
Registered: August 2004
Junior Member
hi,
i have a text file containing multiple lines in windows.my oracle database is on a linux machine which reads this file.i am able to read this file from linux via samba.but the problem i am now facing is ... linux is not able to read ^M character present in the text file.i tried the dos2unix command to convert the text file.no doubt it eliminated the ^M character but now the multiple lines appearing in original text file now appears in a single line.is there anyway by which only the ^M character will be removed but the text files will appear in multiple lines instead of one.

thanks in advance and it is very urgent please.
regards,
sam
Re: Urgent.reading files in linux. [message #99253 is a reply to message #99252] Wed, 29 December 2004 01:50 Go to previous messageGo to next message
Daniel Kingshott
Messages: 9
Registered: March 2004
Junior Member
Hey,

You need a program called dos2unix, you may also repair this file with a sed or perl command.

If you google for it you will find all the information you require.

Cheers,

dan.
Re: Urgent.reading files in linux. [message #99254 is a reply to message #99253] Wed, 29 December 2004 02:13 Go to previous messageGo to next message
Samyak
Messages: 10
Registered: August 2004
Junior Member
thanks,
i got it...but now how to include this command so that all files are read automatically in that fashion and we donot have to do it manually...
Re: Urgent.reading files in linux. [message #99255 is a reply to message #99254] Wed, 29 December 2004 02:18 Go to previous messageGo to next message
Daniel Kingshott
Messages: 9
Registered: March 2004
Junior Member
You can't read all files through this automatically, besides, why whould you want to and isn't that a bit stupid? it would also waste a lot of processor power.

Instead save the .txt file in the correct format within notepad or what ever, set the encoding to (I believe UTF-8 or Unicode)

OR even better, use a linux desktop :)

dan.
Re: Urgent.reading files in linux. [message #99256 is a reply to message #99255] Wed, 29 December 2004 02:53 Go to previous messageGo to next message
Samyak
Messages: 10
Registered: August 2004
Junior Member
this is because our system is a huge one in terms of processing information....
here a lot of say about 10000 files per day will be downloaded
into a windows machine....now the database which is on linux will read all these files and process them accordingly....now it will be quite tedious to type the command dos2unix everytime for each file and remove the ^M character from the file and then it can be used for processing... morever the multiple lines of the windows file are converted into a single line after removal of ^M character which will make really difficult to know where the line really breaks...
that is the problem.....hope u understood....
thanks......
Re: Urgent.reading files in linux. [message #99257 is a reply to message #99256] Wed, 29 December 2004 03:00 Go to previous messageGo to next message
Daniel Kingshott
Messages: 9
Registered: March 2004
Junior Member
Well not knowing the ins and outs of your system I can't suggest a specific solution, you will probably have to write a shell script of some sort to process the files as they are placed on the system.

If the 10k files a day are being generated automatically you might want to speak to author of the program generating the files in the first place and ask them to amend the coding of the files.

Other wise, you could try something funky like this:

find /somewhere/on/your/filesystem/where/the/files/live -ctime -2min -exec dos2unix {} ;

and schedule it to run once every 2 minutes, this will look for files created within the last two minutes and process them with dos2unix.

hth,

dan.
Re: Urgent.reading files in linux. [message #99258 is a reply to message #99257] Wed, 29 December 2004 03:33 Go to previous message
Samyak
Messages: 10
Registered: August 2004
Junior Member
actually the author of the files is an automated system itself...ofcourse third party....
anyway your suggestion is worth a try....
thanks a lot for your views and taking pains to reply....
regards,
sam
Previous Topic: Write to Linux FIFO
Next Topic: urgent -- moving files from windows to linux
Goto Forum:
  


Current Time: Sun Dec 04 05:38:05 CST 2022