Advertisement
cd62131

common ancestor in file list

Feb 26th, 2023
880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.25 KB | None | 0 0
  1. #!/bin/bash -eu
  2. list=$(mktemp)
  3. trap 'rm -f -- ${list}' EXIT
  4. cat - >${list}
  5. n=$(wc -l <${list})
  6. dir=$(head -1 ${list} | xargs dirname)
  7. while (( n != $(find ${dir} -type f | wc -l) )); do dir=$(dirname ${dir}); done
  8. echo $(basename ${dir})
  9. exit
  10.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement