#!/usr/bin/awk -f # Downloadable example 3 for GNU Awk Part 14 { # Split the path up into components n = split($0,a,"/") if (n < 2) { print "Error in path",$0 > "/dev/stderr" next } # Build the shell command so we can show it cmd = sprintf("[ -e %s ] && ln -s -f %s %s",$0,$0,a[n]) print ">> " cmd # Feed the command to the shell printf("%s\n",cmd) | "sh" } END { close("sh") }