find

Can someone explain the inner working of the symbols at the end of this bash: “_ {} \;”

随声附和 提交于 2019-12-30 07:03:02
问题 I ran the following command in shell to batch convert .HEIC files to .JPG files, the command is successful, however there's a part of it I don't understand: find . -name '*.HEIC' -exec sh -c 'magick convert $1 "${1%.HEIC}.JPG"' _ {} \; Apparently _ {} acts to assign find result to $1 , but how? I can't find an explanation on google nor here, and didn't have any luck with man find . It's entirely possible that answers were here but these symbols are not very nice to search for. So the question

How to find the number of occurrences of a string in file using windows command line?

时光怂恿深爱的人放手 提交于 2019-12-30 04:04:53
问题 I have a huge files with e-mail addresses and I would like to count how many of them are in this file. How can I do that using Windows' command line ? I have tried this but it just prints the matching lines. (btw : all e-mails are contained in one line) findstr /c:"@" mail.txt 回答1: Using what you have, you could pipe the results through a find . I've seen something like this used from time to time. findstr /c:"@" mail.txt | find /c /v "GarbageStringDefNotInYourResults" So you are counting the

How do I find all of the symlinks in a directory tree?

你离开我真会死。 提交于 2019-12-29 10:08:08
问题 I'm trying to find all of the symlinks within a directory tree for my website. I know that I can use find to do this but I can't figure out how to recursively check the directories. I've tried this command: find /var/www/ -type l … and later I discovered that the contents in /var/www are symlinks, so I've changed the command to: find -L /var/www/ -type l it take a while to run, however I'm getting no matches. How do I get this to check subdirectories? 回答1: This will recursively traverse the

How do I find all the positions of a substring in a string?

混江龙づ霸主 提交于 2019-12-29 06:44:09
问题 I want to search a large string for all the locations of a string. 回答1: The two other answers are correct but they are very slow and have O(N^2) complexity. But there is the Knuth-Morris-Pratt algorithm, which finds all substrings in O(N) complexity. Edit: Also, there is another algorithm: the so-called "Z-function" with O(N) complexity, but I couldn't find an English source for this algorithm (maybe because there is also another more famous one with same name - the Z-function of Riman), so I

C++ const std::map reference fails to compile

故事扮演 提交于 2019-12-29 05:50:12
问题 Is there a reason why passing a reference to a std::map as const causes the [] operator to break? I get this compiler error (gcc 4.2) when I use const: error: no match for ‘operator[]’ in ‘map[name]’ Here's the function prototype: void func(const char ch, std::string &str, const std::map<std::string, std::string> &map); And, I should mention that there is no problem when I remove the const keyword in front of std::map . If I've been instructed correctly, the [] operator will actually insert a

total size of group of files selected with 'find'

一个人想着一个人 提交于 2019-12-28 08:07:23
问题 For instance, I have a large filesystem that is filling up faster than I expected. So I look for what's being added: find /rapidly_shrinking_drive/ -type f -mtime -1 -ls | less And I find, well, lots of stuff. Thousands of files of six-seven types. I can single out a type and count them: find /rapidly_shrinking_drive/ -name "*offender1*" -mtime -1 -ls | wc -l but what I'd really like is to be able to get the total size on disk of these files: find /rapidly_shrinking_drive/ -name "*offender1*"

How to use fill_in with find in Capybara (if possible)

有些话、适合烂在心里 提交于 2019-12-28 08:06:13
问题 I'd like to do the following but can't due to the nature of fill_in expecting a locator as the first argument. find(:css, "input[id$='donation_pledge_hundreds']").fill_in :with => "10" I've also tried doing element = find(:css, "input[id$='donation_pledge_hundreds']") fill_in element.<method> , :with => "10" but there are no methods that return any data to identify the element to fill_in. Any ideas of the best way of finding a field via a regex for use with fill_in? 回答1: Going from memory so

How do I get the find command to print out the file size with the file name?

最后都变了- 提交于 2019-12-28 07:58:40
问题 If I issue the find command as follows: $ find . -name *.ear It prints out: ./dir1/dir2/earFile1.ear ./dir1/dir2/earFile2.ear ./dir1/dir3/earFile1.ear What I want to 'print' to the command line is the name and the size: ./dir1/dir2/earFile1.ear 5000 KB ./dir1/dir2/earFile2.ear 5400 KB ./dir1/dir3/earFile1.ear 5400 KB 回答1: find . -name '*.ear' -exec ls -lh {} \; just the h extra from jer.drab.org's reply. saves time converting to MB mentally ;) 回答2: You need to use -exec or -printf. Printf

C#: Searching a text in Word and getting the range of the result

独自空忆成欢 提交于 2019-12-28 06:21:32
问题 I can find a text in a Word file via: Word.Range range = wordApp.ActiveDocument.Content; Word.Find find = range.Find; find.Text = "xxx"; find.ClearFormatting(); find.Execute(ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); This tells me if the text is found. But I need the range of the found text-piece. 回答1: Have you tried this: range.Find.Execute(

C#: Searching a text in Word and getting the range of the result

北城余情 提交于 2019-12-28 06:21:05
问题 I can find a text in a Word file via: Word.Range range = wordApp.ActiveDocument.Content; Word.Find find = range.Find; find.Text = "xxx"; find.ClearFormatting(); find.Execute(ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); This tells me if the text is found. But I need the range of the found text-piece. 回答1: Have you tried this: range.Find.Execute(