In fewer than 64 keystrokes.
perl -e 'print ((0..9,a..f)[rand(16)]) for 1..64; print "\n"'
That's all one line in case it wraps for you. Credit to Brian for the code.
Monday, March 31, 2008
Friday, March 28, 2008
Aren't all end of lines equal?
If you've ever opened a text file from Unix using Notepad, you already know the answer; no, they are not. Windows represents the end of line (EOL) with CRLF (0x0d 0x0a), whereas Unix's EOL is just the LF (0x0a). Usually this isn't a problem. View your log files over samba using TextPad or another editor that's smarter than notepad and you're good to go. But what if you need to convert from one format to the other? Enter perl. On a Unix box, to "correct" the Windows EOL, run perl -pi -e "s/\r//" filename. Translation: run perl, doing an in place edit on the input file (the -i), printing each line in the file after edited (the -p) executing (the -e) a substitution (s///) of every carriage return (\r) with nothing. On Windows, to "correct" the Unix EOL, run perl -pi.bkp -e '' filename. This translation is a bit odder. The Windows version of perl won't let you do an in place edit w/o a backup (the .bkp). The Windows Perl recognizes both versions of EOL, but always prints the Windows one, so we just do an in place edit that boils down to reading and printing each line.
Subscribe to:
Posts (Atom)