#!/bin/bash function output { echo "after $1" | tclsh echo -n "$1 " } function sort { for i in $* do output $i & done } sort $* wait # use tclsh sleep instead of bash sleep. 1000 times efficiency.