Created
June 2, 2021 11:39
-
-
Save maxandersen/98fdbeb6ac9e978923ff7cd6967a0257 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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