positional-operator

bash find, only delete files - order of arguments

人走茶凉 提交于 2020-01-21 14:22:05
问题 Say today is April 8th and I execute the following in bash. cd /tmp mkdir hello touch -d 2015-04-01 hello Then, say I want to delete all files in /tmp that are older than one day, but NOT directories and I execute this: find /tmp -mtime +1 -delete -type f Why is directory "hello" deleted if it's not a file? Thanks! 回答1: The find command executes the expression in order. Since -delete is before -type , -type is never reached. Try: find /tmp -mtime +1 -type f -delete 回答2: David C. Rankin's

bash find, only delete files - order of arguments

孤街醉人 提交于 2020-01-21 14:21:56
问题 Say today is April 8th and I execute the following in bash. cd /tmp mkdir hello touch -d 2015-04-01 hello Then, say I want to delete all files in /tmp that are older than one day, but NOT directories and I execute this: find /tmp -mtime +1 -delete -type f Why is directory "hello" deleted if it's not a file? Thanks! 回答1: The find command executes the expression in order. Since -delete is before -type , -type is never reached. Try: find /tmp -mtime +1 -type f -delete 回答2: David C. Rankin's

bash find, only delete files - order of arguments

霸气de小男生 提交于 2020-01-21 14:20:28
问题 Say today is April 8th and I execute the following in bash. cd /tmp mkdir hello touch -d 2015-04-01 hello Then, say I want to delete all files in /tmp that are older than one day, but NOT directories and I execute this: find /tmp -mtime +1 -delete -type f Why is directory "hello" deleted if it's not a file? Thanks! 回答1: The find command executes the expression in order. Since -delete is before -type , -type is never reached. Try: find /tmp -mtime +1 -type f -delete 回答2: David C. Rankin's

Using MongoDB's positional operator $ in a deeply nested document query

这一生的挚爱 提交于 2019-12-30 08:23:16
问题 Is it possible to use positional operator '$' in combination with a query on a deeply-nested document array? Consider the following nested document defining a 'user': { username: 'test', kingdoms: [ { buildings: [ { type: 'castle' }, { type: 'treasury' }, ... ] }, ... ] } We'd like to return the 'castles' for a particular user e.g. in a form: { kingdoms: [{ buildings: [{ type: 'castle' }] }] } Because you cannot use the $ operator twice (https://jira.mongodb.org/browse/server-831) I know that

Using positional operator for multiple levels of subdocuments [duplicate]

删除回忆录丶 提交于 2019-12-11 18:36:07
问题 This question already has answers here : Multiple use of the positional `$` operator to update nested arrays (2 answers) Closed 3 years ago . I am using sub-documents in mongodb. With one level of sub-documents, I can update documents with Parent.findOneAndUpdate({ _id: parentId, 'children._id': childId }, { $set: { 'children.$.name': name } }, (err, doc) => { ... }); but I have problems doing the same for another level of sub-documents, i.e. Parent.findOneAndUpdate({ _id: parentId, 'children

How to use MongoDB's Postional Operator in C# code?

你离开我真会死。 提交于 2019-12-10 18:31:35
问题 I want to use the positional operator of the MongoDB in C# code. Here is data structure for Customer: { name:"Robert", age:40, addresses:[ {street:"...", city:"New York", country:"USA", ...}, {street:"...", city:"California", country:"USA", ...}, ], } So, if I want to update the street value where the address if of New York city, I use this query in MongoDB: db.customer.update( { "addresses.city" : "New York"}, { $set : { "addresses.$" : {"street":"New street", city:"New York", country:"USA",

bash find, only delete files - order of arguments

拈花ヽ惹草 提交于 2019-12-01 23:51:57
Say today is April 8th and I execute the following in bash. cd /tmp mkdir hello touch -d 2015-04-01 hello Then, say I want to delete all files in /tmp that are older than one day, but NOT directories and I execute this: find /tmp -mtime +1 -delete -type f Why is directory "hello" deleted if it's not a file? Thanks! The find command executes the expression in order. Since -delete is before -type , -type is never reached. Try: find /tmp -mtime +1 -type f -delete mklement0 David C. Rankin's helpful answer uses the correct abstract term, expression , to refer to the list of arguments starting with

Python argparse positional arguments and sub-commands

拈花ヽ惹草 提交于 2019-11-30 18:16:31
I'm working with argparse and am trying to mix sub-commands and positional arguments, and the following issue came up. This code runs fine: import argparse parser = argparse.ArgumentParser() subparsers = parser.add_subparsers() parser.add_argument('positional') subparsers.add_parser('subpositional') parser.parse_args('subpositional positional'.split()) The above code parses the args into Namespace(positional='positional') , however when I change the positional argument to have nargs='?' as such: import argparse parser = argparse.ArgumentParser() subparsers = parser.add_subparsers() parser.add

Python argparse positional arguments and sub-commands

混江龙づ霸主 提交于 2019-11-30 02:23:50
问题 I'm working with argparse and am trying to mix sub-commands and positional arguments, and the following issue came up. This code runs fine: import argparse parser = argparse.ArgumentParser() subparsers = parser.add_subparsers() parser.add_argument('positional') subparsers.add_parser('subpositional') parser.parse_args('subpositional positional'.split()) The above code parses the args into Namespace(positional='positional') , however when I change the positional argument to have nargs='?' as