find iregex
I'm trying to put together a shell script (one liner) that will backup the contents of a specified directory into a gzipped tarball. I'm trying to filter out what I want backed up with find's iregexp option but I'm stuck. Does the -iregexp treat parenthesis as metacharacters because I'm not getting the results I want?
Here is the script I'm using. Problem is with the (), they don't seem to be treated as the proper regular expression because nothing is returned. Code:
find media/ -iregex '.*\.(jpg|jpeg)' The final script should look something like this Code:
find media/ -iregex '.*\.(jpg|jpeg)' | xargs tar -cvzf backup.tar.gz |
Hi,
These three: ( ) and | are special: find media/ -iregex '.*\.\(jpg\|jpeg\)' Tested the above, so it should work. |
Quote:
|
EDIT: Nevermind, ayecee helped me on irc. He recommended that I use print0 along with xargs -0 to achieve what I wanted.
[s]If I were to use these as arguments for another shell cmd, you wouldn't happen to know how to put each line in quotes so the cmd won't break if the files or directorys have spaces in them.[/s] |
All times are GMT -5. The time now is 08:34 PM. |