find

Find -regex is slower than find | grep

[亡魂溺海] 提交于 2019-12-12 19:53:38
问题 I have a script which looks for a file using a regular expression. The code was the following: find $dir | grep "$regex" The script run a bit too slow and I want to optimise it. The search takes some time to perform and I would like to get better performance out of it. I've tried this attempt: find $dir -regex ".*${regex}.*" I was expecting slightly faster results as no extra process is created to parse the regular expression. However the result was different and to my astonishment the

MySQL Finding Substring Matches and Group by Match Full Word

六月ゝ 毕业季﹏ 提交于 2019-12-12 17:46:23
问题 Working with MySQL and I can't find the right combination of terms for this expression. Using a PHP user input variable in my statement, I need to find a partial substring match and group by the full match word Taking example input "#bea" I want to find matches for "#bea" as a substring in full text posts, then group by and count the full word where it matches such as "#beat" , "#beauty" , "#beast" With example posts in database Testing Post #beat #beauty Another test #beauty #beast Testing

JS: Handle with find() property undefined

て烟熏妆下的殇ゞ 提交于 2019-12-12 17:14:31
问题 I have a method which returns a value from an element in the array. Not all the elements have the property I want to return. I would like to do this function with one line using the method find() . I've tried this way to solve it: getExecsFromTour(tourId){ return this.repInfo.find(el => el.id == tourId ).execs || []; } But the elements which don't contain the property execs return an error of undefined . To solve it, I had to store the result in a local variable: getExecsFromTour(tourId){ let

Find and Replace RegEx question

穿精又带淫゛_ 提交于 2019-12-12 16:23:54
问题 I am starting to get a grip on RegEx thanks to all the great help here on SO with my other questions. But I am still suck on this one: My code is: StreamReader reader = new StreamReader(fDialog.FileName.ToString()); string content = reader.ReadToEnd(); reader.Close(); I am reading in a text file and I want to search for this text and change it (the X and Y value always follow each other in my text file): X17.8Y-1. But this text can also be X16.1Y2.3 (the values will always be different after

Using find or grep to locate filenames with accented characters from a different encoding system (Windows to Linux)

不打扰是莪最后的温柔 提交于 2019-12-12 15:49:21
问题 I tried to tag late onto a question similar to mine (Find Non-UTF8 Filenames on Linux File System) to elicit further replies, with no luck so far, so here goes again... I have the same problem as the OP in the link above and convmv is a great tool to fix one's own filesystem. My question is therefore academic, but I find it unsatisfactory (in fact I can't believe) that 'find' is not able to find non standard ascii characters. Is there anyone out there that would know what combination of

Find symbolic links in a directory

て烟熏妆下的殇ゞ 提交于 2019-12-12 15:01:29
问题 How can one recursively find all the symbolic links in a directory in Unix? Something like this find . -name *.o but for symbolic links along the lines of find . -type symlink ??? 回答1: find . -type l Should work. http://linuxmanpages.com/man1/find.1.php 来源: https://stackoverflow.com/questions/4611595/find-symbolic-links-in-a-directory

find -exec option

谁说我不能喝 提交于 2019-12-12 14:33:42
问题 Say , i want to find some files and do chmod and do something with it with another command, eg find . -name "*.txt" -exec chmod 666 "{}" && cp "{}" /dst \; it says find: missing argument to `-exec' How do I properly use this -exec construct? I think the problem is with the "&&" ? I need to use this && operator in case chmod fails thank you 回答1: Just use another -exec e.g. find . -name \*.txt -exec chmod 666 {} \; -exec cp {} /dst/ \; 回答2: Either write a little shell script and -exec that or

Project wide word matching search on Xcode 5

╄→гoц情女王★ 提交于 2019-12-12 12:12:48
问题 I'm using Xcode 5, and want to find a word (ex:variable name) not by substring match but by exact match (or prefix match). In file wide search (Command-F), I can use Textual search or regular expression search by clicking the arrow button just right of the glass icon and choosing "Edit Find Options...". But, I cannot find any option to search on project wide search ("Find in Project", Shift-Command-F), in Xcode 5. One thing I can do is run "grep -w" on Terminal.app. But, isn't there any way

Bash find and move files with '[ ]' in name

主宰稳场 提交于 2019-12-12 11:55:56
问题 Part of a bash script I'm making involves rar splitting files and then moving the split files to another directory once they are done. So if I have a file like "test file.txt", it would first get rarred to "[test] file.txt.part1.rar", "test file.txt.part2.rar", and then both of the rar's would get moved to another directory. I have the rar bit working fine, but i'm having trouble on the find & move. Here's my script: #!/bin/bash # [...] rar a -m0 -v104857600b "$1.rar" "$1"; find $folder -name

C++ Using .find() with struct as key in map

↘锁芯ラ 提交于 2019-12-12 11:28:35
问题 All I do not have access to BOOST or STL my struct and map looks similar to the following psuedo: struct s_map_key{ int a; int b; bool operator<(const s_map_key& smk) const { if (a < smk.a) { return true; } else if (a == smk.a) { if (b < smk.b) { return true; } else if (b == smk.b) { return true; } } return false; } }; int main(int argc, char* argv[]) { std::multimap<s_map_key, std::string> myMap; for(int i = 0; i <10; i++) { s_map_key smk; smk.a = i; smk.b = 2; myMap.insert(std::make_pair