process countLines { publishDir '/work/data', mode: 'copy' input: path file output: path "${file.simpleName}.count", emit:count script: """ wc -l $file > ${file.simpleName}.count """ } workflow { Channel.fromPath("/work/data/*.txt") | countLines }