Results 1 to 3 of 3
Hey, so i have a function in my bashrc that i use to shred files recursively. it's something like this.
Code:
find "$1" -name "$2" -exec shred -uzvn 6 '{}' ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-20-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 21
Pass wildcards as parameters.
Hey, so i have a function in my bashrc that i use to shred files recursively. it's something like this.
Code:find "$1" -name "$2" -exec shred -uzvn 6 '{}' \;
it works fine if i pass it parameters like:
but when i pass it say a parameter likeCode:$ function ~/ foo*
Code:$ function ~/ *
it will lift a file name out of my current working directory and pass it as a parameter. so essentially, it tries to find that erroneous file name in the directory specified. how do i prevent this without using any special input?
EDIT: it appears if i pass the parameter as a literal, ie with 'single quotes' all works fine, but is there any way to achieve this solely inside the script?
thanks.Last edited by TheJanitor; 10-20-2010 at 02:32 AM.
- 10-20-2010 #2Linux Newbie
- Join Date
- Mar 2010
- Posts
- 152
No - the * token is expanded by the shell before your program gets hold of it, so you cannot see it. Furthermore, you probably don't really want to do this - as you've found out, there's a way to explicitly bypass this behaviour, and subverting what users expect the shell to do normally will only lead to confusion.
- 10-22-2010 #3Just Joined!
- Join Date
- Jun 2010
- Posts
- 21
yeah thanks, it was a stupid question really. thank you.


Reply With Quote

