Skip to content

Instantly share code, notes, and snippets.

@maxandersen
Created June 2, 2021 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxandersen/98fdbeb6ac9e978923ff7cd6967a0257 to your computer and use it in GitHub Desktop.
Save maxandersen/98fdbeb6ac9e978923ff7cd6967a0257 to your computer and use it in GitHub Desktop.
///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.zeroturnaround:zt-exec:1.12
//DEPS org.slf4j:slf4j-nop:1.7.30
import static java.lang.System.*;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import org.zeroturnaround.exec.*;
public class demo {
public static void main(String... args) throws InvalidExitValueException, IOException, InterruptedException, TimeoutException {
int count = Integer.parseInt(new ProcessExecutor().command("/bin/bash", "-c", "set -euo pipefail;ls -1 | wc -l")
.readOutput(true).execute()
.outputUTF8().trim());
out.println("Files count: "+ count);
}
}
let count = parseInt(await $`ls -1 | wc -l`)
console.log(`Files count: ${count}`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment