Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. FILES=(path/to/*.txt)
  2.  
  3. shopt -s extglob
  4. files=(path/to/!(manifest).txt)
  5.  
  6. declare -a files=()
  7. for file in /path/to/files/*
  8. do
  9. ! [[ -e "$file" ]] || [[ "$file" = */manifest.txt ]] || files+=("$file")
  10. done
  11.  
  12. FILES=($(ls /path/to/*.txt | grep -wv '^manifest.txt$'))
  13.  
  14. $ touch f{1..6}.txt manifest.txt
  15. $ ls *.txt
  16. f1.txt f3.txt f5.txt manifest.txt
  17. f2.txt f4.txt f6.txt
  18.  
  19. declare -A exclude
  20. for f in f1.txt f5.txt manifest.txt; do
  21. exclude[$f]=1
  22. done
  23.  
  24. files=()
  25. for fn in *.txt; do
  26. [[ ${exclude[$fn]} ]] && continue
  27. files+=("$fn")
  28. done
  29.  
  30. $ echo "${files[@]}"
  31. f2.txt f3.txt f4.txt f6.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement