fork(2) download
  1. #!/bin/bash
  2. result=("school/proj_1/file1.txt" "school/proj_1/file2.txt" "school/proj_1/file3.txt")
  3. rx='school/proj_1/(.*)'
  4. for i in "${result[@]}"; do
  5. echo "${i##*/}"
  6. if [[ "$i" =~ $rx ]]; then
  7. echo "${BASH_REMATCH[1]}"
  8. fi
  9. done
  10.  
  11.  
Success #stdin #stdout 0s 4308KB
stdin
Standard input is empty
stdout
file1.txt
file1.txt
file2.txt
file2.txt
file3.txt
file3.txt