From 6b3f339593e80cde2e85e102c6cd16cf0ac784d7 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Wed, 24 Jul 2019 10:50:34 +0200 Subject: [PATCH] Add take script Reads N arguments from stdin and prints them --- bin/take | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 bin/take diff --git a/bin/take b/bin/take new file mode 100755 index 0000000..d26ecff --- /dev/null +++ b/bin/take @@ -0,0 +1,20 @@ +#!/usr/bin/env lua + +local num, command = ..., table.concat({select(2, ...)}, ' ') + +local input do + if command == '' then + input = io.stdin + else + input = io.popen(command) + end +end + +for i=1,num do + local input = input:read '*l' + if input then + print(input) + else + break + end +end