X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/blobdiff_plain/bf9fed34f59ced6a0ffc1196d68803ad27904a0a..232791f70bcecbe0f55634fe44dbf9980004a6c5:/unitproc/bkt-remove_leading_zeroes diff --git a/unitproc/bkt-remove_leading_zeroes b/unitproc/bkt-remove_leading_zeroes index d934e93..503dd40 100755 --- a/unitproc/bkt-remove_leading_zeroes +++ b/unitproc/bkt-remove_leading_zeroes @@ -1,48 +1,14 @@ #!/bin/bash -read_stdin() { - # Desc: Consumes stdin; outputs as stdout lines - # Input: stdin (consumes) - # Output: stdout (newline delimited) - # return 0 stdin read - # return 1 stdin not present - # Example: printf "foo\nbar\n" | read_stdin - # Depends: GNU bash (version 5.1.16), GNU Coreutils 8.32 (cat) - # Version: 0.1.1 - # Attrib: Steven Baltakatei Sandoval (2024-01-29). reboil.com - local input_stdin output; - - # Store stdin - if [[ -p /dev/stdin ]]; then - input_stdin="$(cat -)" || { - echo "FATAL:Error reading stdin." 1>&2; return 1; }; - else - return 1; - fi; - - # Store as output array elements - ## Read in stdin - if [[ -n $input_stdin ]]; then - while read -r line; do - output+=("$line"); - done < <(printf "%s\n" "$input_stdin") || { - echo "FATAL:Error parsing stdin."; return 1; }; - fi; - - # Print to stdout - printf "%s\n" "${output[@]}"; - - return 0; -}; # read stdin to stdout lines remove_leading_zeroes() { # Desc: Removes leading zeroes from lines # Input: stdin # Output: stdout # Depends: BK-2020-03 read_stdin() - # Version: 0.0.1 + # Version: 0.0.2 while read -r line; do printf "%s\n" "$line" | sed -E -e 's/(^0*)([0-9].*)/\2/'; - done < <(read_stdin); + done; }; printf "00000.jpg\n0001.jpg\n2.jpg\n000003.jpg\n0010.jpg\n";