I have a text file full of thousands of md5 hashes from around the interwebs but they are seperated with newlines.
I need to open the txt hash file, and write to another file but replacing every newline with nothing.
Possible languages: Perl, C++ or Visual Basic 6.
Name:
Anonymous2007-05-13 2:19 ID:qNHJAn5T
YOu should just create a structure and save each line of your txt file in the structre and then write your structure in another txt file only if the containt of the structure isnt empty.
In vb.net it would be something like
for i=0 to stucture.length
if struc(i)<>"" then
FileName.WriteLine(struct(i))
end if
next
sorry I dont really the syntax in VB6
Name:
Anonymous2007-05-13 2:22 ID:/R3s1xXj
perl: perl -pl0e'#'
of course a real programmer would do it in c: #include <stdio.h>
int main(){
int len;
char* line;
while(!feof(stdin)){
line=fgetln(stdin,&len);
char l2[len+1];
memcpy(l2,line,len);
if(!feof(stdin))--len;
l2[len]='\0';
fputs(l2,stdout);
}
return 0;
}
main :: IO ()
main = do
arg <- getArgs
case arg of
[from,to] -> do
content <- readFile from
`catch` (\_ -> fail $ "file does not exit: " ++ from)
writeFile to (filter (== '\n') content)
`catch` (\_ -> fail $ "could not write to file: " ++ to)
_ ->
fail "invalid arguments. use <fromfile> <tofile>"
This has the advantage of actually being fast: [code]$ wc irc/Updike\,\ John\ -\ Rabbit\,\ Run\(v1.1\)\[htm\].html
11617 102746 615253 irc/Updike, John - Rabbit, Run(v1.1)[htm].html
$ time ./whut irc/Updike\,\ John\ -\ Rabbit\,\ Run\(v1.1\)\[htm\].html blah
>>23
There's too many VB and Java "professionals" here to keep stuff simple and elegant, live with it.
I'm not saying you couldn't be a decent programmer and work with Java, it's just that most people who prefer it over other languages aren't that skilled in others.
>>30
The amount of magic symbols used in idiosyncratic perl code makes it completely unreadable to anyone except other perl programmers.
Name:
Anonymous2007-05-13 22:43 ID:UHeJtlXS
The proper way to deal with the OP is to question his motives.
Why would you want to remove newlines from the file? Either store the hashes in a text file with some sort of separator, or store them as pure binary. Not some kind of shit semi-text format.
Name:
Anonymous2007-05-13 23:26 ID:Qg00uqNK
>>32
good call. No clue why anyone would store without a notifiable seperator.
>>33
Going for world record? "Largest concatenated md5 hash".
Mad scientist experiment? "Yes... I hold all the world's md5 hashes hostage, and if I do not get ONE MILIEEN DOLLARS within 24 hours, I will squeeeeze them together until the information density creates a deegital black hole, sucking the tubes of the eenternet dry!"
Post it on messageboards to make a really long unbroken line and fucking up the page layout?
Name:
Anonymous2007-05-13 23:42 ID:nJ3/ypUI
Because md5 hashes have a static length, regardless of whether they're stored in binary form or as a hex string. OP is probably too retarded to know that the hexadecimal can also be `converted' into binary.
|
|
RESPOND TO THREAD | CHECK /SCI/ AGAIN
ON /SCI/ | A FEW HOURS LATER
|
|
|
|
|
--------------------------------|--------------------------------
|FFFFFFFFFFFFFFFFFFFFFFFFF
|FFFFFFFFFFFFFFFFFFFFFFFFF
|FFFFFFFFFFFFFFFFFFFFFFFFF
REALIZE NOONE HAS |FFFFFFFFFFFFFFFFFFFFFFFFF
POSTED ANYTHING SINCE |FFFFFFFFFFFFFFFFFFFFFFFFF
ALL DAY |UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|
|
RESPOND TO | CHECK /SCI/ AGAIN
THREAD ON /SCI/ | A FEW HOURS LATER
|
|
|
|
|
--------------------------------|--------------------------------
|FFFFFFFFFFFFFFFFFFFFFFFFF
|FFFFFFFFFFFFFFFFFFFFFFFFF
REALIZE NOONE |FFFFFFFFFFFFFFFFFFFFFFFFF
HAS POSTED ANYTHING |FFFFFFFFFFFFFFFFFFFFFFFFF
SINCE YOU LEFT |FFFFFFFFFFFFFFFFFFFFFFFFF
|UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|
|
RESPOND TO | CHECK /SCI/ AGAIN
THREAD ON /SCI/ | A FEW HOURS LATER
|
|
|
|
|
--------------------------------|--------------------------------
|FFFFFFFFFFFFFFFFFFFFFFFFF
|FFFFFFFFFFFFFFFFFFFFFFFFF
REALIZE NOONE |FFFFFFFFFFFFFFFFFFFFFFFFF
HAS POSTED |FFFFFFFFFFFFFFFFFFFFFFFFF
ANYTHING SINCE |FFFFFFFFFFFFFFFFFFFFFFFFF
YOU LEFT |UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|
|
RESPOND TO | CHECK /SCI/ AGAIN
THREAD ON /SCI/ | A FEW HOURS LATER
|
|
|
|
|
--------------------------------|--------------------------------
|FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
REALIZE NOONE |FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
ELSE HAS POSTED |FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
ANYTHING SINCE |FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
YOU LEFT |UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU
|UUUUUUUUUUUUUUUUUUUUUUUUU