Created
June 21, 2023 12:21
-
-
Save nkh/06592beceae023d692aa0fe90d425283 to your computer and use it in GitHub Desktop.
bash read loop and zero-ing scrip
This file contains hidden or 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
#!/bin/bash | |
[[ $1 == -0 ]] && { shift ; while read -d $'\0' -r I ; do eval "$1" ; done ; } || { while read -r I ; do eval "$1" ; done ; } | |
#!/usr/bin/env -S perl -p | |
chomp ; $_.="\0" | |
# example where everything is zero ended | |
find -size +5M -mtime -700 -not -path "*/video_backup/*" -group nadim -print0 | \ | |
perl -0ne 'chomp ; !-e "$_.sha256" && print "$_\n"' | +0 | \ | |
-n -0 'mimemagic "$I" | grep -q mp4 && echo "$I"' | +0 | \ | |
-n -0 'exiftool "$I" | grep -i rotation | grep -q 0 && echo "$I"' | |
# nothing zero ended, would work as well because none of the tool involved | |
# split on space | |
# zero-ing is useful when tools like xargs (see -d) split on space | |
find -size +5M -mtime -700 -not -path "*/video_backup/*" -group nadim | \ | |
perl -ne 'chomp ; !-e "$_.sha256" && print "$_\n"' | \ | |
-n 'mimemagic "$I" | grep -q mp4 && echo "$I"' | \ | |
-n 'exiftool "$I" | grep -i rotation | grep -q 0 && echo "$I"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment