i have to rewrite a script in order to be compatible with file lines
ending by CR instead of unix \n
my script is simple, it take the content of a folder and merge the file
all together in a unique file, those files have CR lines ending and such
must be the merged file.
i have to rewrite a script in order to be compatible with file lines
ending by CR instead of unix \n
my script is simple, it take the content of a folder and merge the file
all together in a unique file, those files have CR lines ending and such
must be the merged file.
what to do in that case ?
You could do something like
untested
File.open(“result.txt”, “wb”) do |out|
Dir["*"].each do |file|
File.open(file) do |in|
in.each_line do |line|
line.chomp!
out.write(line)
out.write("\r\n")
end
end
end
end
i have to rewrite a script in order to be compatible with file lines
ending by CR instead of unix \n
my script is simple, it take the content of a folder and merge the
file
all together in a unique file, those files have CR lines ending and
such
must be the merged file.
If you need to work line-by-line instad of slurping them (which would
be easier and line-ending agnostic), then pass CR as the optional
separator to your line-oriented idiom. For example