fork download
  1. #!/bin/bash
  2. s='/a/b/c/d.txt
  3. /a/b/c/d/e.txt
  4. f
  5. g
  6. h/i
  7. /a/b/c.txt'
  8. awk -F/ '$NF ~ /\.txt$/{$NF="";print}' OFS=/ <<< "$s"
Success #stdin #stdout 0.01s 5440KB
stdin
Standard input is empty
stdout
/a/b/c/
/a/b/c/d/
/a/b/