Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #!/bin/bash
  2. while mapfile -d '' -t -n 5 filenames; do
  3. out=()
  4. for item in "${filenames[@]}"; do
  5. if [[ $item = *token1* || $item = *token2* ]]; then
  6. out+=("$item")
  7. fi
  8. done
  9. printf '%s\0' "${out[@]}" | xargs -0 other-binary
  10. done
  11. # If I were actually doing this,
  12. # I'd have used `grep -Zv -e token1 -e token2` to do the filtering,
  13. # but since the point was for it to be an example filter,
  14. # I'm going to assume that in "real" use, grep couldn't handle it.
  15.  
  16. #!/bin/ruby
  17. STDIN.readlines("\0").map{|item|item.chomp("\0")}
  18. .each_slice(5) do |ary|
  19. out = ary.select{|item|
  20. item.include?("token1") || item.include?("token2")
  21. }
  22. IO::popen(["other-binary"], "w") do |io|
  23. out.each{|item|io.write(item+"\0")}
  24. end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement