|
Selecting file names in a shell - one word or another
If you want to select all file names that include the words "cat" or "dog" in them with file name matching, you can do so using curly braces - that's supported by most modern shells as part of what is known as "globbing".
Here's an example - I've just been copying images off my digital camera and I wanted all files from 28th January, 31st January and 1st February - so file names starting P128, P131 and P201, and this is what I wrote:
cp /Volumes/Untitled/DCIM/100OLYMP/P{128,131,201}* .
Sometimes, there is confusion between square brackets and curly braces in file name matching. If I had written
[128,131,201]
I would have been looking for any ONE character from the list in the brackets - so that's a 0 1 2 3 8 or comma (and the specification of the comma 1 and 2 several times would have shown that I didn't realise what I was doing. And if I had written
[128][131][201]
then I would have been looking for a 1 2 or 8 followed by a 1 or 3 (or 1!) followed by s 2 a 0 or a 1
Oh - want to see one of the pictures?
Nottingham at Night - City Centre (written 2008-02-02 07:29:25)
Associated topics are indexed under A101 - Web Application Deployment - Linux -An Introduction For UsersA167 - Web Application Deployment - Shell Programming
Some other Articles
Expecting a item from a list of possiblesRailway Acronyms and AbbreviationsTcl - learning how to use namespaces, packages and libraries togetherObject Oriented TclSelecting file names in a shell - one word or anotherCarers at work - court case changesJust one thing let the service down - but that is my memoryNottingham - just text!Ive just received an email from myself. Should I be worried?Paging Martin Noke, who petitions for more trains from Trowbridge to Swindon
|
1891 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38 at 50 posts per page
This is a page archived from The Horse's Mouth at
http://www.wellho.net/horse/ -
the diary and writings of Graham Ellis.
Every attempt was made to provide current information at the time the
page was written, but things do move forward in our business - new software
releases, price changes, new techniques. Please check back via
our main site for current courses,
prices, versions, etc - any mention of a price in "The Horse's Mouth"
cannot be taken as an offer to supply at that price.
Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).
|
|