소스 검색

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}"

불러오는 중...
취소
저장