С оболочками POSIX:
for file in *_g_chrom; do
base=${file%_g_chrom}
paste -- "$file" "${base}_g_pos" > "${base}_vcf.txt"
done
Вы можете использовать inotifywait. Пример скрипта:
#!/bin/bash
watchdir="$1"
if ! [ -d "$watchdir" ]; then
echo "Dir $watchdir doesn't exist"
exit 1
fi
while file=$(inotifywait --format "%f" -e 'create' -e 'moved_to' "$watchdir"); do
if [ -f "$watchdir/$file" ]; then
tmpname=$(tempfile -d "$watchdir")
mv "$watchdir/$file" "$tmpname"
mkdir "$watchdir/$file"
mv "$tmpname" "$watchdir/$file/$file"
# YOURCOMMANDS
fi
done