瀏覽代碼

Add parent-urls

master
JustAnotherArchivist 3 年之前
父節點
當前提交
caffebab2e
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. +14
    -0
      parent-urls

+ 14
- 0
parent-urls 查看文件

@@ -0,0 +1,14 @@
#!/bin/bash
prog0='BEGIN { FS="/"; OFS="/" }' # Set the field separators
prog1='{ print }' # Print the input URL (if desired)
prog2='/\/$/ { --NF }' # Remove the trailing blank field if the URL ends with a slash
prog3='{ for (i = NF; i > 3; --i) { --NF; print $0 OFS; } }' # One by one, remove the last path component, print remaining fields

prog="${prog0} "
if [[ "$1" == '--with-original' ]]
then
prog="${prog}${prog1} "
fi
prog="${prog}${prog2} ${prog3}"

exec awk "${prog}"

Loading…
取消
儲存