find

Delete a list of files with find and grep

我是研究僧i 提交于 2021-02-05 12:48:14
问题 I want to delete all files which have names containing a specific word, e.g. "car". So far, I came up with this: find|grep car How do I pass the output to rm? 回答1: find . -name '*car*' -exec rm -f {} \; or pass the output of your pipeline to xargs : find | grep car | xargs rm -f Note that these are very blunt tools, and you are likely to remove files that you did not intend to remove. Also, no effort is made here to deal with files that contain characters such as whitespace (including

Find command find directories that were created after a certain date under Linux/Cygwin

天涯浪子 提交于 2021-02-05 02:36:52
问题 I want to use the find command to find these directories: Access: 2013-12-13 10:59:46.190886900 -0500 Modify: 2013-12-03 07:04:02.995890600 -0500 Change: 2013-12-03 07:04:02.995890600 -0500 Birth: 2013-12-02 07:04:02.000000000 -0500 (I want a time after '12-03') This is the command I ran but it still lists older directories: find . -type d -newerBt '2013-12-03 00:00:00' -exec du -h {} \; How can I modify this line to find the directories created after that date? What is the difference between

Find command find directories that were created after a certain date under Linux/Cygwin

眉间皱痕 提交于 2021-02-05 02:36:02
问题 I want to use the find command to find these directories: Access: 2013-12-13 10:59:46.190886900 -0500 Modify: 2013-12-03 07:04:02.995890600 -0500 Change: 2013-12-03 07:04:02.995890600 -0500 Birth: 2013-12-02 07:04:02.000000000 -0500 (I want a time after '12-03') This is the command I ran but it still lists older directories: find . -type d -newerBt '2013-12-03 00:00:00' -exec du -h {} \; How can I modify this line to find the directories created after that date? What is the difference between

Grep only last line after find needed files

╄→гoц情女王★ 提交于 2021-02-04 21:38:51
问题 Hi guys I have an extended question from this thread I need to find some files given file name and use grep on the last lines of these files to find a certain string. I currently have: find my_dir/ -name "*filename*" | xargs grep 'lookingfor' I'm new to using these commands so much help would be appreciated. Thank you in advance. 回答1: You can for example do: find my_dir/ -name "*filename*" -exec sh -c "tail -200 {} | grep lookingfor" \; setting 200 to the number of last lines you want. 回答2: I

Grep only last line after find needed files

China☆狼群 提交于 2021-02-04 21:38:18
问题 Hi guys I have an extended question from this thread I need to find some files given file name and use grep on the last lines of these files to find a certain string. I currently have: find my_dir/ -name "*filename*" | xargs grep 'lookingfor' I'm new to using these commands so much help would be appreciated. Thank you in advance. 回答1: You can for example do: find my_dir/ -name "*filename*" -exec sh -c "tail -200 {} | grep lookingfor" \; setting 200 to the number of last lines you want. 回答2: I

Mongo - query, Embedded document not match except dot notation

坚强是说给别人听的谎言 提交于 2021-02-04 21:36:36
问题 i am confuse. here is the example: MongoDB Enterprise > db.employee.find() result: {"_id":1002,"name":"Jack","address":{"previous":"Cresent Street","current":"234,Bald Hill Street","unit":"MongoDB" } } I try this: db.employee.find({address:{previous: "Cresent Street"}}) result: nothing returns Next a try this: db.employee.find({"address.previous": "Cresent Street"}) result: {"_id":1002,"name":"Jack","address":{"previous":"Cresent Street","current":"234,Bald Hill Street","unit":"MongoDB"}} The

Python: check for data type in list

拜拜、爱过 提交于 2021-02-04 16:23:06
问题 Is there a way to check if an instance of a specific data type is present in a list / dictionary, without explicitly checking every element / key? I suspect the answer is no. If it does exist, though, I imagine it would be similar to the way you can use the in operator to search for specific elements / keys, like this: 3 in [1, 2, 3] # => True except you'd be checking for an instance of a data type rather than a some specific value, like this: int in [1,"a", 3.4] # => True Any ideas? 回答1:

BASH - Delete files older than 3 months?

雨燕双飞 提交于 2021-02-04 13:39:47
问题 Delete files older than 3 months how? For 90 days i know: find /tmp/*.log -mtime +90 -type f -delete But how do i know 3 months equal to always 90 days? how many exact days? Is there more better way to tell the -mtime to follow months ? 回答1: If you want exact number of days for 3 months then you can use: days=$(( ( $(date '+%s') - $(date -d '3 months ago' '+%s') ) / 86400 )) and use it as: find /tmp/*.log -mtime +$days -type f -delete Or directly in find : find /tmp/*.log -type f \ -mtime "+$

BASH - Delete files older than 3 months?

喜夏-厌秋 提交于 2021-02-04 13:39:08
问题 Delete files older than 3 months how? For 90 days i know: find /tmp/*.log -mtime +90 -type f -delete But how do i know 3 months equal to always 90 days? how many exact days? Is there more better way to tell the -mtime to follow months ? 回答1: If you want exact number of days for 3 months then you can use: days=$(( ( $(date '+%s') - $(date -d '3 months ago' '+%s') ) / 86400 )) and use it as: find /tmp/*.log -mtime +$days -type f -delete Or directly in find : find /tmp/*.log -type f \ -mtime "+$

Need to expand Multiple find and replace in MS Word from a list in MS Excel to replace text w hyperlink and fix error

☆樱花仙子☆ 提交于 2021-02-04 08:26:07
问题 I have a large Word file that refers to multiple Question #s throughout. I also have an Excel file that lists all the Question #s in Column A and in Column B there is a list of actual questions that are also hyperlinks. I would like to replace every question # in the Word document with the corresponding hyperlinked question in Column B of the spreadsheet. I tried to use the macro in the StackOverflow question Multiple find and replace in MS Word from a list in MS Excel, but I get the Run-time