params.str = "Hello, world!" process split { publishDir "results/lower" input: val x output: path 'chunk_*' script: """ printf '${x}' | split -b 6 - chunk_ """ } process to_upper { tag "$y" input: path y output: path 'upper_*' script: """ cat $y | tr '[a-z]' '[A-Z]' > upper_${y} """ } workflow { main: ch_str = channel.of(params.str) ch_chunks = split(ch_str) ch_upper = to_upper(ch_chunks.flatten()) publish: lower = ch_chunks.flatten() upper = ch_upper } output { lower { path 'lower' } upper { path 'upper' } }