Files
hpr_website/www/eps/hpr2816/hpr2816_awk14_ex3.awk

24 lines
439 B
Awk
Executable File

#!/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")
}