Stripping whitespace in a find command
I don't want to strip the beginning or the end.
but I want to do something like find <dir> -iname *<1wd><spaces><2wd>* I've tried find <dir> -iname *1wd\ +2wd* find <dir> -iname *1wd[\ ]+2wd* find <dir> -iname *1wd[\ ]\+2wd* to no avail. |
You want something along the lines of:
Code:
find <dir> -iregex "*wd\ *2wd" e.g. the file: /folder/afile.bat will match with -iregex "folder/a.*\.bat" but not -regex "a.*\.bat" (and any number of spaces would be "\ *") |
do it like this
Code:
find /path -type f -iname "* *" |
ghostdog yours would not work and I tell you why that gets every file with a space.
Let me give you guys a more concrete example. I have 11 files Code:
aaaaab caaaa Code:
aaaaab caaaa |
then add your "b"s and "c"s into the expression. Its easy, so I leave it to you to experiment. the command line is there for you to use.
|
Why not simply a good-ol' pipe?
Code:
find . -type f | grep -E '.*[bB][ ]+[cC].*' |
Quote:
Code:
find /path -type f -iname "wrd1* *wrd2" Code:
find /path -type f -iname "*wrd1* *wrd2*" |
Quote:
Code:
find . -type f <for OP to find out> ".*b[ ]+c.*" |
Putting together suggestions by Komakino, ghostdog74 and catkin, most likely this is what you're looking for:
Code:
find . -type f -iname "*b* *c*" -iregex '.*b[ ]+c.*' |
Quote:
|
Quote:
|
Quote:
|
Quote:
Code:
c:/tmp$ touch 'a b' |
Quote:
Code:
find . -iname "*b* *c*" Code:
blahb blah cblahblah |
Quote:
|
All times are GMT -5. The time now is 03:49 AM. |