[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Recommendations for getting Parallel-like ::: behavior using Bash
From: |
Rhys Ulerich |
Subject: |
Re: Recommendations for getting Parallel-like ::: behavior using Bash |
Date: |
Sat, 22 Mar 2014 23:59:10 -0500 |
> I like how GNU Parallel does its ::: magic ...
>
> Has anyone implemented something similar in pure bash?
My quick version of :::-like processing for bash looks like the following:
declare -a cmd
while [ $# -gt 0 ]; do
[ "$1" = ":::" ] && break
cmd+=("$1")
shift
done
if [ "$1" = ":::" ]; then
while shift && [ $# -gt 0 ]; do
echo "${cmd[@]}" "$1"
done
else
while read line; do
echo "${cmd[@]}" "$line"
done
fi
This breaks on multiple ::: and totally ignores ::::.
An "...Only experts do this on purpose...." homage might go in that
final else clause.
- Rhys