SHARE
TWEET

Untitled

a guest Jul 9th, 2015 23 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top