I threw this together:
> lineNumber=: ([: ;"1 (' ' ,~&.> [: ":&.> [: i. #) ,. <"1)@:([: > _1 {
> [: 5!:2 <)
For example:
> lineNumber 'consolidateBkpsTowardPast'
> 0 NB.* consolidateBkpsTowardPast: copy all contents of successive dirs
> into
> 1 NB. earliest starting with oldest->consolidated backups with newest
> version
> 2 NB. overwriting older ones.
>
> 3 y=. 2{.boxopen y NB. Files' prefix, dir in which to work
>
> 4 pfx=. openbox {.y NB. Prefix is "WL" for laptop, "WD" desktop
>
> 5 if. 0=#>1{y do.
>
> 6 wrkdir=. BASEDSK,'/Temp/'
>
> 7 else. wrkdir=. endSlash >1{y
>
> 8 end.
>
> 9 dd=. jd dir wrkdir,'*.' NB. Just directories
>
> 10 dd=. (<pfx,'[0-9]{8}$') rxfirst&.>dd NB. Only names like
> {pfx}YYYYMMDD
> 11 dd=. \:~dd-.a: NB. Order from most to least recent.
>
> 12 NB. if. -.nameExists 'WTTMINC_TMP_' do.
>
> 13 NB. WTTMINC_TMP_=. 2 1 NB. Add 1 sec to each subsequent wait
>
> 14 NB. end.
>
> 15 if. nameExists 'TOPDIR' do. svTD=. TOPDIR end.
>
> 16 TOPDIR=: (wrkdir rplc '/\';'\') rplc '/\'
>
> 17 2 moveDirOverAnother/\dd
>
> 18 newnm=. nameSpan ({:,{.) dd
>
> 19 cmd=. (TOPDIR{.~>:TOPDIR i. ':'),' && cd ',(TOPDIR}.~>:TOPDIR i.
> ':'),' && '
> 20 cmd=. ((cmd,'ren "',(>{:dd),'" "',newnm,'"') rplc '/\';'\') rplc
> '/\'
> 21 shell cmd
>
> 22 if. nameExists 'svTD' do. TOPDIR=: svTD NB. Re-instate or
>
> 23 else. 4!:55 <'TOPDIR' end. NB. remove global.
>
> 24 NB.EG consolidateBkpsTowardPast 'WD';'C:/Temp/WrkDesk/'
>
On Tue, Aug 25, 2015 at 4:01 PM, Cire <[email protected]> wrote:
> Is there any way to print a listing with line numbers?
>
> [Never do I get to see a reply from my email to [email protected]]
>
> Eric Sargeant
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm