Thanks, erind, for a clear and concise explanation. Tried both your examples and they both worked. Any reason to prefer one over the other?
Thanks, erind, for a clear and concise explanation. Tried both your examples and they both worked. Any reason to prefer one over the other?
Although in this case the first option ("$@") is simpler, with arrays I've noticed an easier handling of individual tokens, as far as shell quoting is concerned. This quote from mywiki.wooledge.org nicely sums it up:
From: http://mywiki.wooledge.org/BashGuide/ParametersArrays are basically indexed lists of strings. They are very convenient for their ability to store multiple strings together without relying on a delimiter to split them apart (which is tedious when done correctly and error-prone when not).
has anyone mentioned that there is a typo in the very first line? two within within's
i am confused by the following part of that wiki
so in this particular case does it matters to use -name or -iname if we were to search for all files that are .ogg or .OGG ?It is important to get into the habit of quoting patterns in your search as seen above or your search results can be a little unpredictable. Such a search can be much more sophisticated though. For example if you wished to search for all of the ogg files in your home directory, some of which you think might be named 'OGG' rather than 'ogg', you would run:
Here the option '-iname' performs a case-insensitive search while the wildcard character '*' matches any character, or number of characters, or zero characters.Code:find $HOME -iname '*.ogg'
i mean we are using the * doesnt that means 'anything' [case or type of char doesnt matter ?] or is the iname for the .ogg there to make that case insensitive ?
thanks ... i would recomend this note/tip to be added to that great wiki..
The 'iname' bit allows the search to be case-insensitive (thus matching either 'ogg' or 'OGG'. The '*' operator allows any text that comes before the '.ogg' bit. The two are exclusive, though. Let's say you have two files called 'file.ogg' and 'file.OGG'. If you search by:
You'll only get 'file.ogg' as a result. If you use -iname, though, you'll get both files as a result, because now the search doesn't care about upper or lowercase file names. Does that make more sense?Code:find $HOME -name '*.ogg'
Last edited by drmrgd; August 9th, 2012 at 07:21 PM. Reason: lousy typos!
^^ thanks ... on first read i got the impression that it wont matter to use either iname or name and so were two of my collegues.. we were mistaken by the * .. whearas the .ogg is also a part of the search pattern..
thanks again ..
I'm looking to be able to find a bunch of pdfs, move those pdfs to another directory, keep the directory structure, and remove the previous structures.
So far I have been able to use the find command and copy the files while keeping the structure:
find /home/john/books1/ -regex ".*\(pdf\|epub\|mobi\)$" -type f -exec cp '{}' /home/john/temp/ ';'
but if I use mv I get all the files in one directory...
find /home/john/books1/ -regex ".*\(pdf\|epub\|mobi\)$" -type f -exec mv -b '{}' /home/john/temp/ ';'
Am I stuck using 'cp'? Which is fine, I just need to find a way to then delete them...
find /home/john/books1/ -regex ".*\(pdf\|epub\|mobi\)$" -type f -exec rm '{}' /home/john/temp/ ';'
I plan to also have this in a cron job but that shouldn't be a problem once I have figured out the script
Thanks for any help
Bookmarks