write_lines

Write an array of strings to a file

File write_lines(Array[String])

Writes a file with one line for each element in a Array[String]. All lines are terminated by the newline (\n) character (following the POSIX standard). If the Array is empty, an empty file is written.

Parameters

  1. Array[String]: Array of strings to write.

Returns: A File.

Example: write_lines_task.wdl

version 1.3

task write_lines {
  input {
    Array[String] array = ["first", "second", "third"]
  }

  command <<<
    paste -s -d'\t' ~{write_lines(array)}
  >>>

  output {
    String s = read_string(stdout())
  }

  requirements {
    container: "ubuntu:latest"
  }
}

Example input:

{}

Example output:

{
  "write_lines.s": "first\tsecond\tthird"
}

The actual command line might look like:

paste -s -d'\t' /local/fs/tmp/array.txt

And /local/fs/tmp/array.txt would contain:

first\nsecond\nthird