Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- while mapfile -d '' -t -n 5 filenames; do
- out=()
- for item in "${filenames[@]}"; do
- if [[ $item = *token1* || $item = *token2* ]]; then
- out+=("$item")
- fi
- done
- printf '%s\0' "${out[@]}" | xargs -0 other-binary
- done
- # If I were actually doing this,
- # I'd have used `grep -Zv -e token1 -e token2` to do the filtering,
- # but since the point was for it to be an example filter,
- # I'm going to assume that in "real" use, grep couldn't handle it.
- #!/bin/ruby
- STDIN.readlines("\0").map{|item|item.chomp("\0")}
- .each_slice(5) do |ary|
- out = ary.select{|item|
- item.include?("token1") || item.include?("token2")
- }
- IO::popen(["other-binary"], "w") do |io|
- out.each{|item|io.write(item+"\0")}
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement