Advertisement
Guest User

Untitled

a guest
Jul 9th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.49 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Setup
  4. touch a.txt
  5. touch b.txt
  6. mkdir foo
  7. touch foo/c.txt
  8. touch foo/d.txt
  9.  
  10. # Wildcard expansion happens here...
  11. files1=( *.txt )
  12. files2=*.txt
  13.  
  14. # ...and not here. There's no way to preserve
  15. # the wildcard in a variable and have it
  16. # evaluated in the "foo/" context.
  17. cd foo
  18. echo "files1 = ${files1[@]}"
  19. echo "files2 = $files2"
  20. echo "*.txt = " *.txt
  21.  
  22. # Output:
  23. #
  24. # files1 = a.txt b.txt
  25. # files2 = *.txt
  26. # *.txt =  c.txt d.txt
  27.  
  28. # Cleanup
  29. cd ..
  30. rm -R a.txt b.txt foo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement