You are not logged in.
Pages: 1
Hi guys,
System can't find a file using command "find" when searched filename contains square bracket [xyz] (can't find when close bracket exist) ie. find /path -type f -size +1M -iname "*file.name.1.2.3-4ABC[xyz]*" I can find when "*file.name.1.2.3-4ABC[xyz*"
Does "find" command can handle that ?
Thanks
Offline
Escape the [ and ]. Enter them as \[ and \]
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
apologies, i forgot to mention my searched filename is variable $filename (result of other function) and because of that i can't modify this string
Offline
apologies, i forgot to mention my searched filename is variable $filename (result of other function) and because of that i can't modify this string
It is possible to modify variables in Bash:
filename=${filename/[/\\[}
filename=${filename/]/\\]}
Offline
It's not working unfortunately, but i fixed my issue by using sed when generating variables.
Thanks
Offline
Can't you just put quotes around the variable? E.g. "$filename" instead of $filename.
Offline
Pages: 1