Category:TXR: Difference between revisions

→‎Simple Query: Revised example: using built-in math that TXR now has.
(→‎Simple Query: [minor] Wording.)
(→‎Simple Query: Revised example: using built-in math that TXR now has.)
Line 52:
<lang txr>#!/usr/bin/txr -f
@(next "/proc/meminfo")
@(define num (n))@\
@(skip)
@(local numtok)@{numtok /[0-9]+/}@(bind n @(int-str numtok 10))@\
MemTotal:@/ +/@TOTAL kB
@(skipend)
MemFree:@/ +/@FREE kB
@(gather)
Buffers:@/ +/@BUFS kB
CachedMemTotal:@/ +/@CACHED(num TOTAL) kB
MemFree:@/ +/@(num FREE) kB
@(skip)
SwapTotalBuffers:@/ +/@SWTOT(num BUFS) kB
Cached: @(num CACHED) kB
SwapFree:@/ +/@SWFRE kB
SwapTotal: @(num SWTOT) kB
@(next `!echo $(( @TOTAL - @FREE ))`)
SwapFree:@/ +/@(num SWFRE) kB
@USED
@(skipend)
@(next `!echo $(( @USED - @BUFS - @CACHED ))`)
@(nextbind `!echoUSED $(@(- @TOTAL - @FREE 10))`)
@RUSED
@(nextbind `!echoRUSED $(@(- @FREEUSED + @BUFS + @CACHED ))`)
@(nextbind `!echoRFREE $(@(+ @USEDFREE - @BUFS - @CACHED ))`)
@RFREE
@(nextbind `!echoSWUSE $(@(- @SWTOT - @SWFRE ))`)
@SWUSE
@(output)
TOTAL USED FREE BUFFERS CACHED
Anonymous user