Here's a quick snippet:
To change my above post (the one with all them thar words) from fusetalk to HTML, you can use something like:
cat doc.txt | sed -e 's/\[b\]/\<b\>/g' -e 's/\[\/b\]/\<\/b\>/g' -e 's/\[i\]/\<i\>/g' -e 's/\[\/i\]/\<\/i\>/g' |
tr '\n' '^'| sed -e 's/\^/\<BR\>/g' >doc2.html
Broken down:
cat doc.txt | - This displays the test of doc.txt (which in this case would be the text of my post with all of the fustalkisms in it). The text will be used as the input for the next part of the command:
sed -e 's/\[b\]/\<b\>/g' -e 's/\[\/b\]/\<\/b\>/g' -e 's/\[i\]/\<i\>/g' -e 's/\[\/i\]/\<\/i\>/g' | \ - This is sed. It's pretty complicated, and I barely understand it. Basically, the 's/something/something_else/g' takes every instance of "something" and switches it with "something_else". The backslashes (\) are there as escape characters, making the shell not interpret < or > as anything but < or >. The pipe makes the output of this command be the input for the next command. The last back slash allows me to hit enter and start the rest of the command on the next line instead of continueing the very long command.
tr '\n' '^'| - This command is new in this thread. tr translates or deletes characters. In this case it should change \n (new line character) to a ^. sed doesn't handle new line characters well, so that is why I chose tr. Unfortunately the second string can only be as long as the first string, or I would switch \n with <br> directly. I chose the ^ character because I hadn't previously used it. If anyone knows a better way to do this, LET ME KNOW!
The pipe makes this output of this command be the input of the next command:
sed -e 's/\^/\<BR\>/g' - This just switches the ^ character with <BR>. The results of all of this go to:
> doc2.html - This puts the output of all previous commands into the file doc2.html.
To change my above post (the one with all them thar words) from fusetalk to HTML, you can use something like:
cat doc.txt | sed -e 's/\[b\]/\<b\>/g' -e 's/\[\/b\]/\<\/b\>/g' -e 's/\[i\]/\<i\>/g' -e 's/\[\/i\]/\<\/i\>/g' |
tr '\n' '^'| sed -e 's/\^/\<BR\>/g' >doc2.html
Broken down:
cat doc.txt | - This displays the test of doc.txt (which in this case would be the text of my post with all of the fustalkisms in it). The text will be used as the input for the next part of the command:
sed -e 's/\[b\]/\<b\>/g' -e 's/\[\/b\]/\<\/b\>/g' -e 's/\[i\]/\<i\>/g' -e 's/\[\/i\]/\<\/i\>/g' | \ - This is sed. It's pretty complicated, and I barely understand it. Basically, the 's/something/something_else/g' takes every instance of "something" and switches it with "something_else". The backslashes (\) are there as escape characters, making the shell not interpret < or > as anything but < or >. The pipe makes the output of this command be the input for the next command. The last back slash allows me to hit enter and start the rest of the command on the next line instead of continueing the very long command.
tr '\n' '^'| - This command is new in this thread. tr translates or deletes characters. In this case it should change \n (new line character) to a ^. sed doesn't handle new line characters well, so that is why I chose tr. Unfortunately the second string can only be as long as the first string, or I would switch \n with <br> directly. I chose the ^ character because I hadn't previously used it. If anyone knows a better way to do this, LET ME KNOW!
sed -e 's/\^/\<BR\>/g' - This just switches the ^ character with <BR>. The results of all of this go to:
> doc2.html - This puts the output of all previous commands into the file doc2.html.