The little things give you away... A collection of various small helper stuff
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

parent-urls 483 B

3 yıl önce
1234567891011121314
  1. #!/bin/bash
  2. prog0='BEGIN { FS="/"; OFS="/" }' # Set the field separators
  3. prog1='{ print }' # Print the input URL (if desired)
  4. prog2='/\/$/ { --NF }' # Remove the trailing blank field if the URL ends with a slash
  5. prog3='{ for (i = NF; i > 3; --i) { --NF; print $0 OFS; } }' # One by one, remove the last path component, print remaining fields
  6. prog="${prog0} "
  7. if [[ "$1" == '--with-original' ]]
  8. then
  9. prog="${prog}${prog1} "
  10. fi
  11. prog="${prog}${prog2} ${prog3}"
  12. exec awk "${prog}"