Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Lmod syntax

35 views
Skip to first unread message

colin

unread,
Feb 28, 2012, 10:21:52 AM2/28/12
to
LMOD is a little filter writen by Horst Schaeffer.

I have just discovered it. It seems many people are familer with it.
I'm hoping some of the people here have used it.

I have put the help at the bottom of this post.

The problem Im having is trying to understand how to use it. It has
several features but I find it hard to get started. I have at least
dont the following tests that work.

TYPE FILE1.TXT | LMOD /L* [4] > FILE2.TXT
TYPE FILE1.TXT | LMOD /L2 [4] > FILE2.TXT (cuts out line 2 at 4
characters)
TYPE FILE1.TXT | LMOD /L2-4 [4] > FILE2.TXT (cuts out line 2 to 4 at 4
characters)
TYPE FILE1.TXT | LMOD /L3* [4] > FILE2.TXT (cuts out line all lines
starting at 2 and cuts it at 4th character.
TYPE FILE1.TXT | LMOD /L*mytext [4] > FILE2.TXT (adds "mytext"
preceding every line.)

But some of the more advanced features seem elusive to me.
Has anyone used it and can they share with me (perhaps others, since I
cant see anyone else providing this helpfull info) any examples to
show how to use some of the more advanced options. Im sure once we see
some examples it will become clear to me.
thanks.
LMOD 1.3 Filter (c) 2002 Horst Schaeffer
Syntax: LMOD options string_with_tokens
Options:
/Ln[-m] line [range] to select (default: first non blank line)
/L[n]* all lines [starting n]
/E include empty input lines (default: no output)
/S.. delimiters for word extraction, instead of default
(,;=)
/B.. as /S, but excluding blank space as delimiter
/Nn starting line number (for token [#]), default: /N001
Insert from source line (expression in square brackets):
[p,l $n U|L Rn] default []: complete line
p,l from position p, length l (default rest of line)
$n word number n ("!" for last word); optionally ±offset
$n:m range of words by number (blank space will be
inserted)
U|L convert to upper|lower case
Rn right aligned in output field of size n
Other tokens:
[+] insert CR+LF
[-] omit CR+LF at end of output
[#] line number (digits acc. to option, default:3)
[=n] tab to position n in output line
[~n] ASCII code n (decimal)
[".."] quoted char/string (use for redirection symbols)

foxidrive

unread,
Feb 28, 2012, 11:06:41 AM2/28/12
to
On 29/02/2012 02:21, colin wrote:
> LMOD is a little filter writen by Horst Schaeffer.
>
> I have just discovered it. It seems many people are familer with it.
> I'm hoping some of the people here have used it.

Horst has some wonderful tools. Lmod was invaluable for Win9x systems where the for /f wasn't available with delims and tokens but much is able to be done natively in Windows NT and later these days.

I did intend using Lmod a lot more and asked Horst if I could post an ascii binary version of Lmod, which you will find below, but then I got into XP and started using the native commands.

The URL listed has changed - but this ascii version can be included in batch files and that was the reason I wanted to include it.


Below the ascii binary you will find some of the ways I used it and should all work with Win98SE.



@echo off
:: Ascii version of Horst Schaeffer's - LMOD 1.3/ASCII
:: Documentation and info: http://home.mnet-online.de/horst.muc/
:: Converted with tools from Herbert Kleebauer
echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>lmod.com
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>lmod.com
echo EvhBYXMiON?iCdQiF@SiPAEi?OcAumHThk`TN_cPhsoTLmnD?MI?mxRTw`>>lmod.com
echo sTqd_SqnqTuILoAiE@ustp@iE@{Ms@Jv~Dq`{Sy{EOcAv@RB11??zABFyg>>lmod.com
echo Et@CzFIYLj@KB~?is?@OBBEcqGzRBZfvv~{S@{JO{Eq@AvYDB_Ko?zRHFy>>lmod.com
echo ?_t@zPFIEgj@Bq~?Lg?@z@BEsPGzBMZfq\}UBf?FP`q@{OCwF?EBsP]sj1>>lmod.com
echo ?IBBQ??O?jepHjep?KIazohBAfM?eLrPfevBBeAC}E@vgtNveBY\eQj[fu>>lmod.com
echo vB~?AwFu@CQN}1~lg~I?YxAIowiBiMYLcNsRHmUL@KiKs@ULcNsB{OZ{jB>>lmod.com
echo ifsLYLcNDRjkcsQvB?j{?AzAJUHmAAKSL?suJB`kJSU`zUM`i???As?ZJ`>>lmod.com
echo Lbxc}`}GO_HFq`?zqJ~s?Gr`LR?jAoEWJ}DY?_OtZFs~D]WgIk?D~zNBtP>>lmod.com
echo jUt={?DGCtYCjM?Eq~CW}HVWJJAw?ZjksY{O{koG\sLCtH{O_oJGuBiutF>>lmod.com
echo BRAjvNaBiu{?bJDsYCL{kA?utltL{OjEBs{?wJ@tIC]@EPEJAwFqlCSE@C>>lmod.com
echo UUBEJB?kJ?]`u_M`E}?{vqy[?spJzlbNrA]PFIgJ}Hg~HCtPmjB=guGEta>>lmod.com
echo {OCGCwbHBt]zORJrAsBFIQ{?HxEtaCsa{ODjFN}1gzy?sLCtqF}mgrZji}>>lmod.com
echo ?]JE_MJEA]zCIarhgBFsi}YkBqa~YUJEuyz[=?wZt_~RjNBsJBrnMjNRwu>>lmod.com
echo YsY]JEa]BCu1z[JRmVDINHaFGq]zwREuYCFEJLtj_{?B1lt`{OIEEcjgUp>>lmod.com
echo AvLG}Kgvt?C]?}A{kOIms_{O{MzFCsjCtl{OIETcAvoJ}mgrl}?MuAtpA?>>lmod.com
echo WrqAx`FB@{q?EPe?VWv?i_QgDK?D}zG@sPGO=?wBu`@GO?k?E`sk{OvMzf>>lmod.com
echo vgD{?D=z?Et`tD~RHG@cE_Ep?eE@fEEF{k?Gzs_sc{M@EntPg~q}g}V~G~>>lmod.com
echo rlkeU`s_{O{MzFXtyC{kEHzs_ssc{OgMvvy~WLugUPUIBWUGgW{kfGzsks>>lmod.com
echo s_{OgMvv{=iKDtTDiM?E{E@CDtKDiM?EkEAcs_{OgMzv{=NK\tQDCvEH=v>>lmod.com
echo gvt?D]EJBW?D_w=Ks@s~~1EHFWM?aWkCi_s_{O{MzFAs\DHBxn?Y}`?e}@>>lmod.com
echo gGtpg}1}j}p}UIQWAge[A}}~fUyCoDv`ji_wEup1sCiOdgBkBw}~1A~IW}>>lmod.com
echo HE[uJEA~@movfsL{kA{jsLEtZDZ{?QECtPgji}]uHEl{kAB@tptj{OLwHG>>lmod.com
echo HjIgjW}p={]@vZt`egC{?D{zG@sPJ@HmEjFRGjWooCu`ir_k{~jBStaC{C>>lmod.com
echo IAKs\DsL{O{EGCBsaCmji}{fjBLt}DgBvq?{nmrB~RjiBwb{U?eKtPOEJE>>lmod.com
echo h}IE{ygzMEjR}rgvkOq`s_{O{MzFCt\DehE\Ej~NiZoe]uJEkEEF{k@G@t>>lmod.com
echo LChiBzk~Ols_{O{MzF@snCkEBfzjg~FP~EsR{SA{FOEWtpFLDO_{kAiIs`>>lmod.com
echo p~@]sqFs?zhFi?oa{LjNvtKDgHvqe{p[t?D]e?@SGEHEl{?A?Ds`ty{OvE>>lmod.com
echo QcVgHKze{FuGEPHeEcjKEp{?EGDtiCM?EXj@joM{QQvRt`ugH{HezfoOE`>>lmod.com
echo wgHohEGE~zhvtD{SM?FWhAjo{~oLTtVDgBvqCzSnAt?Fs?}ncuQ{cEHE~V>>lmod.com
echo hvkEEFJyAgZg@KNh{n@}?g{k?Gzs_sL{M@@Es`~n{?yKt`zFq`g?@ohz~~>>lmod.com
echo g?opH~gky[u`j1AA@zHJ?s?Wg`Lruzq~CjE@eTtTCE~FEJeXzeCCqGEPZD>>lmod.com
echo hzuEtpAjE@gfsp{}{KIslCWUJE{Fg~ILwAAyjiNJ1wzPhks?@_`L?LjM?E>>lmod.com
echo ~eGsuOEpGjE@uqsx@jE@eIsPCEJEEzePaqKck}?EEt@C@\yIz=gv??zAL}>>lmod.com
echo sq@z`G}s?Gs`LbEIKX`LkK?Fq@????@???????~~~~?@~B?????????1AA>>lmod.com
echo ??????????????A?B@??????zk_???=???????????????????????????>>lmod.com
echo ??????????K?}OCNLTmp_?@nrOHBRTl_H@mh_SyneDsg_SyosDgnnOdlnT>>lmod.com
echo mlmSlsdDkmnTdmhTdcmSngnSsrqTtlmSLnb@A{IgxzvWIsBWw`LbrK~V`L>>lmod.com
echo AKFc=A}jhz0x>>lmod.com
::
::LMOD 1.3 Filter (c) 2002 Horst Schaeffer
::Syntax: LMOD options string_with_tokens
::Options:
:: /Ln[-m] line [range] to select (default: first non blank line)
:: /L[n]* all lines [starting n]
:: /E include empty input lines (default: no output)
:: /S.. delimiters for word extraction, instead of default (,;=)
:: /B.. as /S, but excluding blank space as delimiter
:: /Nn starting line number (for token [#]), default: /N001
::Insert from source line (expression in square brackets):
:: [p,l $n U|L Rn] default []: complete line
:: p,l from position p, length l (default rest of line)
:: $n word number n ("!" for last word); optionally ąoffset
:: $n:m range of words by number (blank space will be inserted)
:: U|L convert to upper|lower case
:: Rn right aligned in output field of size n
::Other tokens:
:: [+] insert CR+LF
:: [-] omit CR+LF at end of output
:: [#] line number (digits acc. to option, default:3)
:: [=n] tab to position n in output line
:: [~n] ASCII code n (decimal)
:: [".."] quoted char/string (use for redirection symbols)




::======================================================================
:: Renames *.* to *-date-time.* and uses LMOD and LOGECHO from
:: http://home.nikocity.de/horst.muc/int/index.htm
:: and Microsoft's FIND - Tested with Windows 98 SE
:: execute and examine temp2.bat first to check the output.
:: then remove the :: from the two lines below and rerun it
@echo off
logecho set d8t=$D$M$Y-$h$m$s>temp.bat
call temp.bat
del temp.bat
dir *.* /b /o:n /-p /a:-d>temp.000
type temp.000|find /v /i "temp.000">temp.001
type temp.001|lmod /L1* /B. @ren "[$1].[$2]" "[$1]-%d8t%.[$2]">temp2.bat
:: call temp2.bat
:: del temp2.bat
del temp.000
del temp.001
set d8t=



::======================================================================
@echo off
:: creates brief MP3 list in each directory on C: with directoryname.txt as list filename
dir c:\ /a:d /o:n /s /b /-p >c:\dirlist.txt
type c:\dirlist.txt|lmod /l* /b\ dir [1]\*.mp3 /b /on[~62]"[1]\[$!].txt">c:\mp3list2.bat
del c:\dirlist.txt
:: call c:\mp3list2.bat


::======================================================================
echo.|date|lmod /s/ set date=[29,2][$6][$5]>temp.bat


::======================================================================
dir o:\|find " dir(s) "|lmod /l* Drive O: has [19]


::======================================================================
cd|lmod /S\ set d=[$!]>%temp%.\temp001.bat





--
Mic

colin

unread,
Feb 28, 2012, 2:08:50 PM2/28/12
to
Thanks.
I have never seen a program put together in ascii before. Facinating.
Your added aditional commands also help in fleshing out the lmod
command.

I'm not sure how to use the
[+] insert CR+LF

Option. Does anyone have any samples of that.

Basiclly I have a file that is being created that is a long ascii file
eg 100's of characters long. (on the same line) I need to be able to
cut the long line into specific sizes. The first being column 25 and
then the rest every 46 characters along.

Regards

Herbert Kleebauer

unread,
Feb 28, 2012, 3:10:15 PM2/28/12
to
On 28.02.2012 20:08, colin wrote:

> Basiclly I have a file that is being created that is a long ascii file
> eg 100's of characters long. (on the same line) I need to be able to
> cut the long line into specific sizes. The first being column 25 and
> then the rest every 46 characters along.


Why not us a few lines of assembly code (as long as you are using
a 32 bit Windows or DOS):


@echo off
echo hD1X-s0P_kUHP0UxGWX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>bat.com
echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>bat.com
echo xa0/u9O/8aSji//hz3nqB6WQKI7ko8FW5r7H1QAVW5E29E@E2pQ7npxk...>>bat.com
bat.com <infile.txt >outfile.txt
del bat.com




The source code:


@=$100

move.w #25,r4

move.w #buf,r1
_10: move.w r4,r2
move.w #46,r4
move.b #$3f,m0
eor.w r3,r3
trap #$21
bcs.b _100
tst.w r0,r0
beq.b _100

move.w r0,r5
lea.w 2.b(r5.w),r2
move.w #$0a0d,buf(r5.w)

move.b #$40,m0
inc.w r3
trap #$21
bcc.b _10
_100: rts.w


buf:

foxidrive

unread,
Feb 28, 2012, 10:19:20 PM2/28/12
to
I echoed this string through lmod - all one one line.

m:\>echo 1234567890123456789012345a234567890123456789012345678901234567890123456b234567890123456789012345678901234567890123456c12345|
lmod [1,25][+][26,46][+][72,46][+][118,46][+][164,46]



Herbert had some fun providing you an exact solution too I see. :)


--
Mic

colin

unread,
Feb 29, 2012, 8:34:17 AM2/29/12
to
Thanks for that. the reason I don't do assembly is well um, because I
don't know it, and didn't really know it could do this. Maybe I will
research it, if its not too hard.
I have used Sed, awk and cut in the past on Unix, I even think there
is a way to write scripts in Vi, my old editor friend.
I could have loaded Cywin or what ever its called for windows but I
never find it works very well, and didnt want solution that demanded
that I install tons of crap. I need to pass the solution on to others
who are not technical, and who just need to do the job.


thanks for the assembly.

colin

unread,
Feb 29, 2012, 8:36:18 AM2/29/12
to
On Feb 28, 10:19 pm, foxidrive <foxidr...@gotcha.woohoo.invalid>
wrote:
Thanks for your script as well it, shows me how to use lmod with +.
Maybe I'm dumb, (that's what my wife keeps telling me) But I found it
hard to understand how to use lmod. Thanks for some clarity. I hope
this will help others too.

Regards

tonysathre

unread,
Mar 22, 2012, 7:36:53 AM3/22/12
to
On Feb 28, 11:06 am, foxidrive <foxidr...@gotcha.woohoo.invalid>
wrote:
> ::        $n      word number n ("!" for last word); optionally ±offset
Would you mind explaining how echoing ascii into a file makes the file
executable? In Linux if you do something like that it's not executable
until you set the executable bit to on with chmod +x, or by echoing
out all the ascii into an already existing binary, overwriting it.

How does Windows differentiate between an ascii file and a binary?
Just the extension?

Sorry for being off topic, but it's kind of interesting.

Thanks,

Tony

foxidrive

unread,
Mar 22, 2012, 9:07:22 AM3/22/12
to
On 22/03/2012 22:36, tonysathre wrote:

>> @echo off
>> :: Ascii version of Horst Schaeffer's - LMOD 1.3/ASCII
>> :: Documentation and info:http://home.mnet-online.de/horst.muc/
>> :: Converted with tools from Herbert Kleebauer
>> echo Bj@jzh`0X-`/PPPPPPa(DE(DM(DO(Dh(Ls(Lu(LX(LeZRR]EEEUYRX2Dx=>lmod.com
>> echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>lmod.com

> Would you mind explaining how echoing ascii into a file makes the file
> executable? In Linux if you do something like that it's not executable
> until you set the executable bit to on with chmod +x, or by echoing
> out all the ascii into an already existing binary, overwriting it.

> How does Windows differentiate between an ascii file and a binary?
> Just the extension?

The extension is primarily the mechanism - and of course the file contents must be an executable.

Files often have a header too, such as an .EXE file always starts with MZ and has a defined structure.

A .ZIP file always starts with PK and .GIF files start with GIF89 and some programs recognise the filetype not by the extension but by the contents which I believe is also the mechanism in Linux.

.COM files do not have a defines header.



--
Mic

tonysathre

unread,
Mar 22, 2012, 9:22:45 AM3/22/12
to
Ah yes that makes sense. If you run the file command against a file on
Linux it looks at the file header to determine the actual filetype.
Forgot about that.

Tony
0 new messages