Computing.Net > Forums > Unix > Text Formatting

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Text Formatting

Reply to Message Icon

Name: LANkrypt0
Date: March 9, 2004 at 13:48:58 Pacific
OS: Linux
CPU/Ram: 1
Comment:

I wrote a simple, completely random, monoalphabetic cipher program. Basically swaps one letter for another. The output comes as one big block of jumbled letters. (examples below) I want to get some specifig formatting on the output to make it look neater. I imagine this would probably be done with awk/sed (hopefully a one liner)

The output I get now is something like:
nalhdfthlxgvatxrayadoxguonynoadhtirgxawdfynaxgnghcluxracfdhtngyfdfkdsraid

I would like the output to appear as:
nalhd fthlx gvatx rayad oxguo nynoa dhtir gxawd fynax gnghc luxra cfdht ngyfd fkdsr aid

If you could help me out it would be greatly appreciated.

thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: LANkrypt0
Date: March 9, 2004 at 14:11:30 Pacific
Reply:

Ok I discovered that:
sed -e "s/...../& /g"
works, but only for smaller files. Does anyone have a solution that will work for larger 100K+ files?


0

Response Number 2
Name: FishMonger
Date: March 9, 2004 at 16:38:06 Pacific
Reply:

perl -pi -e 's/\G(.{0,5})/$1 /g' cipher.txt


0

Response Number 3
Name: Dlonra
Date: March 10, 2004 at 18:31:14 Pacific
Reply:

your example shows no spaces. If you are swapping letters, what happens to spaces and other punctuation?


0

Response Number 4
Name: LANkrypt0
Date: March 11, 2004 at 06:53:42 Pacific
Reply:

I get rid of spaces by default, however if you wish to retain them, I created a -formatting tag.

FishMonger, thank you, I shall try that out.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Text Formatting

sed dropping last line of file www.computing.net/answers/unix/sed-dropping-last-line-of-file/5125.html

vms to unix file conversion www.computing.net/answers/unix/vms-to-unix-file-conversion/346.html

very urgent query as i am new here www.computing.net/answers/unix/very-urgent-query-as-i-am-new-here/7957.html