Add take script
Reads N arguments from stdin and prints them
This commit is contained in:
parent
37884e03ac
commit
6b3f339593
1 changed files with 20 additions and 0 deletions
20
bin/take
Executable file
20
bin/take
Executable file
|
@ -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
|
Loading…
Reference in a new issue