Quantcast
Channel: How can I find broken symlinks - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 14

Answer by liz for How can I find broken symlinks

$
0
0

I took

find ./ -type l -exec file {} \; | that.awk

and piped it into an Awk script, that way you can do whatever.

#!/bin/awk -f# ==============================================================================BEGIN {      FS=":"      w=7}# =============================================================================={   sub(/^ /,"",$2)               # remove leading spc   p=index($2,"to")              # 'to' pointer   s=substr($2,1,p-2)            # status   t=substr($2,p+3)              # target   switch(s)   {      case /^broken.*/ :         printf("\n")         printf("%"w"s %s\n","target:",t)         printf("%"w"s %s\n","source:",$1)         printf("%"w"s %s\n","status:",s)         break#      default:#         printf("\n")#         printf("%"w"s %s\n","target:",t)   }}# ==============================================================================END {}# ==============================================================================# functions# ==============================================================================

Viewing all articles
Browse latest Browse all 14

Latest Images

Trending Articles





Latest Images