You are not logged in.
Pages: 1
ok, I want to remove all newlines from a file... I don't think sed will work, as it reads line by line.... does anyone know a way to do this?
FYI, I have an xml file, some 8000 lines long, which has some bad newlines just due to the sheer size... as in:
<someNode a="a" b="b" something="som<NEWLINE>
ething"/>
and I want it to go away 8(
Offline
why does nobody like tr?
echo -e "n" | tr -d 'n'
Offline
wow, rock on!
there's little utilities like that that I totally forget about all the time...
kinda like "modinfo"
Offline
Took me way too long to discover "tee"...
Offline
in python there is replace() method, like...
file = open("path/to/file", "r")
string = file.read()
file.close()
string_new = string.replace("n", "")
file = open("/path/to/file_new", "w")
file.write(string_new)
file.close()
that should fix it,
arch + gentoo + initng + python = enlisy
Offline
I tried that in .NET, actually, and for some reason it wasn't working.... the basic process was:
call a stored procedure
convert massive results to XML
stream XML to file
real simple... however String.Replace wasn't doing crap for the newlines... I dunno why...but it always had embedded newlines at the worst places...
seeing as this is one of those apps where ya go "aha something changed, time to regenerate the XML file" every month or so, it wasn't important *how* it's done... so I was just going to pipe it to tr (found a windows version).
On a side note, I did get the procedure down from taking ~7mins to run to under a minute... hooray for optimization!
Offline
I don't think sed will work, as it reads line by line.... does anyone know a way to do this?
It's possible but tr is much easier. See 5.10 from
http://www.student.northpark.edu/pement … dfaq5.html
Offline
vim -c '%s/n//' <file>
If I got the question right. :-)
BR,
klapmuetz
Hello girls, I like rock climbing, mountain biking and rafting! Write me!
Offline
btw. why is this topic not in the programming forum (I needed to search for it).
Offline
btw. why is this topic not in the programming forum (I needed to search for it).
good question - I should move it
Offline
Pages: 1