User:Eriksiers/to OS: Difference between revisions
m
updated lang tag
(→Shell Script: untested changes) |
m (updated lang tag) |
||
Line 5:
This is done without using any libraries. (FB can use various regex libs, including [[wp:Perl Compatible Regular Expressions|PCRE]].)
<
OPTION EXPLICIT
Line 99:
f_IN = DIR$
WEND
NEXT</
==[[PowerBASIC]]==
Line 109:
Also unlike FreeBASIC, when reading in a line from a text file via <code>LINE INPUT #</code>, only CRLF is recognized as EOL.
<
SUB replacer(fileIN AS STRING, tgtName AS STRING, target AS STRING)
Line 171:
MSGBOX "Done."
$ENDIF
END FUNCTION</
==[[:Category:UNIX Shell|Shell Script]]==
Line 179:
This script decides what to do based on the script's name: <i>source</i>2<i>target</i>. (This is handled by <code>case</code>.) The translation is performed by <code>sed</code>.
<
dos2unix)
sed s/\r//g $1>$1.unix
Line 198:
sed s/\n/\r/g $1>$1.mac
;;
esac</
An alternative would be to make this rather generic. It could be called <code>from</code>, and could be called similar to this:
Line 204:
...which would write the output to "file.txt.unix".
<
dos)
first=\r\n
Line 244:
esac
esac
sed -b s/$first/$second/g $f>$f.$2</
|