mitrichbel Цитата: что такое SBS2?
Вот описание
[more=sbs2.com]=============================================================
= SBS2.COM - By Herbert Kleebauer =
=============================================================
Usage: sbs2.com NUMBER "STRING1" "STRING2" <infile >outfile
infile and outfile must not be the same file!
Substitutes the NUMBER ocurrence of STRING1 in infile by
STRING2 and writes the result to outfile
You can include any character in STRING1/2 by using its
hex value (e.g. $0d for <CR> or $1a for EOF)
If NUMBER = 0 all STRING1 are substituted by STRING2
If an error is detected or nothing is substituted, erorrlevel=0
replace the original file only if errorlevel>=1 (=number of
substitutions).
Instead of the double quotes (") you can also use single quotes (')
with a different meaning for string2:
"string2" : normal substitution
'string2" : before substitution the output file is rewinded
"string2' : after substitution the outputfile is closed
some examples:
------------------------------------------------------
Substitutes the 2. occurrence of user by Susan
------------------------------------------------------
sbs2.com 2 "user" "Susan" <%1 >_._
if errorlevel 1 copy _._ %1
del _._
------------------------------------------------------
Converts dos textfiles to unix textfiles
------------------------------------------------------
sbs2.com 0 "$0d" "" <%1 >_._
if errorlevel 1 copy _._ %1
del _._
------------------------------------------------------
Converts unix textfiles to dos textfiles
------------------------------------------------------
sbs2.com 0 "$0a" "$0d$0a" <%1 >_._
if errorlevel 1 copy _._ %1
del _._
------------------------------------------------------
echo without CRLF
------------------------------------------------------
echo set a=|sbs2.com 0 "$0d$0a" "" >_.bat
------------------------------------------------------
Remove trailing blanks from all lines
------------------------------------------------------
:start
sbs2.com 0 " $0d" "$0d" <%1 >_._
if not errorlevel 1 goto ende
copy _._ %1
goto start
:ende
del _._
------------------------------------------------------
Remove all single CR LF (ascii text file -> WORD)
------------------------------------------------------
sbs2.com 0 "$0d$0a$0d$0a" "$0a" <%1 >_._
if errorlevel 1 copy _._ %1
sbs2.com 0 "$0d$0a" "" <%1 >_._
if errorlevel 1 copy _._ %1
sbs2.com 0 "$0a" "$0d$0a" <%1 >_._
if errorlevel 1 copy _._ %1
del _._
------------------------------------------------------
Extract line 5-9 from a text file
------------------------------------------------------
sbs2.com 4 "$0d$0a" '" <%1 >_._
if errorlevel 1 copy _._ %1
sbs2.com 5 "$0d$0a" "$0d$0a' <%1 >_._
if errorlevel 1 copy _._ %1
------------------------------------------------------
Source code: see older posting in alt.msdos.batch
------------------------------------------------------
=============================================================
Sample batch file to show how to use the code
=============================================================
@echo off
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>sbs2.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU!WvX0GwUY Wv;ovBX2Gv0ExGIuht6>>sbs2.com
echo ?@}IKuNWpe~Fpe?FNHlF?wGMECIQqo{Ox{T?kPv@jeoSeIlRFD@{AyEKj@>>sbs2.com
echo iqe~1NeAyR?mHAG~BGRgB{~H?o~TsdgCYqe?HR~upkpBG?~slJBCyA?@xA>>sbs2.com
echo LZp{xq`Cs?H[C_vHDyB?Hos@QslFA@wQ~~x}viH}`LYNBGyA?@xAB?sUq`>>sbs2.com
echo LRy@PwtCYQEuFK@A~BxPtDss@fFqjVmzD@qBEOEenU?`eHHeBCMs?FExep>>sbs2.com
echo LHsPBGyA?@xAunjzA}EKNs@CA?wQpQpKLBHv?s`WJ`LRCYyIWMJaejCksl>>sbs2.com
echo H[GyFGhHBwHZjjHeoFasuFUJeHeB?OsQH[xeHCPvqFj@oq@eNc?~}Nu??O>>sbs2.com
echo ~oEwoAjBKs?Zp`LBzHQzyEFrAWAG{EFrAqAGYwHTECIQ{coKIsaCsf{Oe~>>sbs2.com
echo CK}Ayre~CNFA{rAyEKFACrA{EKGAjbA}eKGSjNMtQFtc{OAyDGFj?{FDGQ>>sbs2.com
echo KAjNVk_OCAx@e?f{o?CosI}1EGizhljJ~H1ZeG}JBA~rACBMDGjjDG@g0>>sbs2.com
sbs2.com 0 "Old String" "New String" < infile > outfile
del sbs2.com
[/more]