#!/bin/bash process_file() { echo "Processing $1" # echo -n "First 100 bytes of $file: " # | od -An -t x1 # dd bs=1 count=100 if="$file" 2>/dev/null dd bs=1 count=100 if="$1" >/dev/null 2>&1 } export -f process_file if [ "$#" -ne 1 ]; then echo "Usage: $0 directory" exit 1 fi if [ ! -d "$1" ]; then echo "Directory $1 does not exist." exit 1 fi find "$1" -type f -print0 | xargs -0 -n1 -P20 -I{} bash -c 'process_file "$@"' _ {}