Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Setup
- touch a.txt
- touch b.txt
- mkdir foo
- touch foo/c.txt
- touch foo/d.txt
- # Wildcard expansion happens here...
- files1=( *.txt )
- files2=*.txt
- # ...and not here. There's no way to preserve
- # the wildcard in a variable and have it
- # evaluated in the "foo/" context.
- cd foo
- echo "files1 = ${files1[@]}"
- echo "files2 = $files2"
- echo "*.txt = " *.txt
- # Output:
- #
- # files1 = a.txt b.txt
- # files2 = *.txt
- # *.txt = c.txt d.txt
- # Cleanup
- cd ..
- rm -R a.txt b.txt foo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement