find

Using an alias in find -exec

邮差的信 提交于 2019-12-19 05:08:14
问题 I have a very long command in bash, which I do not want to type all the time, so I put an alias in my .profile alias foo='...' Now I want to execute this alias using find -exec find . -exec foo '{}' \; but find cannot find foo: find: foo: No such file or directory Is it possible to use an alias in find? 回答1: Nope, find doesn't know anything about your aliases. Aliases are not like environment variables in that they aren't "inherited" by child processes. You can create a shell script with the

Find value in spreadsheet using google script

青春壹個敷衍的年華 提交于 2019-12-19 04:55:14
问题 Situation: 1 spreadsheet multiple sheets 1 cell selected (may vary) What I'd like to do is to find and set focus to the next cell in any sheet that matches the selected cell (case insensitive) upon clicking a button-like image in the spreadsheet. Sort of like a custom index MS Word can create for you. My approach is: - set value of the selected cell as the variable (succeeded) - find the first cell that matches that variable (not the selected cell) (no success) - set value of found cell as

grouping predicates in find

孤街浪徒 提交于 2019-12-19 03:20:58
问题 This part " ( -name *txt -o -name *html ) " confuses me in the code: find $HOME \( -name \*txt -o -name \*html \) -print0 | xargs -0 grep -li vpn Can someone explain the the brackets and "-o"? Is "-o" a command or a parameter? I know the brackets are escaped by "\" , but why are they for? 回答1: By default, the conditions in the find argument list are 'and'ed together. The -o option means 'or'. If you wrote: find $HOME -name \*txt -o -name \*html -print0 then there is no output action

Find Maven repository where a dependency is stored

廉价感情. 提交于 2019-12-18 16:49:47
问题 I'm working on a project with several corporate remote Maven repositories, each hosting many dozens of dependencies. The entire project uses hundreds of dependencies and I need a way to quickly determine which remote repository a dependency is stored on . Does Maven provide an easy way to do this or do I need to search through each repository's dependency listing myself? 回答1: The project dependencies report has the information you want. You can quickly generate just this report using mvn

Getting Index of an item in an arraylist;

白昼怎懂夜的黑 提交于 2019-12-18 14:12:12
问题 I have a Class called AuctionItem . The AuctionItem Class has a method called getName() that returns a String . If I have an ArrayList of type AuctionItem , what is the best way to return the index of an item in the ArrayList that has a specific name? I know that there is an .indexOf() function. The parameter for this function is an object. To find the item that has a name, should I just use a for loop, and when the item is found, return the element position in the ArrayList ? Is there a

regular expression to exclude filetypes from find

ぐ巨炮叔叔 提交于 2019-12-18 14:09:17
问题 When using find command in linux, one can add a -regex flag that uses emacs regualr expressions to match. I want find to look for all files except .jar files and .ear files. what would be the regular expression in this case? Thanks 回答1: You don't need a regex here. You can use find with the -name and -not options: find . -not -name "*.jar" -not -name "*.ear" A more concise (but less readable) version of the above is: find . ! \( -name "*.jar" -o -name "*.ear" \) 回答2: EDIT: New approach: Since

Why does “find . -name *.txt | xargs du -hc” give multiple totals?

半腔热情 提交于 2019-12-18 13:21:34
问题 I have a large set of directories for which I'm trying to calculate the sum total size of several hundred .txt files. I tried this, which mostly works: find . -name *.txt | xargs du -hc But instead of giving me one total at the end, I get several. My guess is that the pipe will only pass on so many lines of find's output at a time, and du just operates on each batch as it comes. Is there a way around this? Thanks! Alex 回答1: How about using the --files0-from option to du? You'd have to

Search by date using command line

落爺英雄遲暮 提交于 2019-12-18 12:56:19
问题 Is there any way to search for files in a directory based on date? I want to find all files with created date greater than a specific date, is it possible to do it with dir command? 回答1: dir by itself can not filter by date, but you can parse the output of dir using for command. If in your country dir prints the date in YMD format, then you only need to compare it with given date. If the order of date parts is different, then you have to use another for command to parse the date and change it

Is there an STL algorithm to find the last instance of a value in a sequence?

被刻印的时光 ゝ 提交于 2019-12-18 12:51:41
问题 Using STL, I want to find the last instance of a certain value in a sequence. This example will find the first instance of 0 in a vector of ints. #include <algorithm> #include <iterator> #include <vector> typedef std::vector<int> intvec; intvec values; // ... ints are added to values intvec::const_iterator split = std::find(values.begin(), values.end(), 0); Now I can use split to do things to the subranges begin() .. split and split .. end() . I want to do something similar, but with split

Is there an STL algorithm to find the last instance of a value in a sequence?

帅比萌擦擦* 提交于 2019-12-18 12:50:02
问题 Using STL, I want to find the last instance of a certain value in a sequence. This example will find the first instance of 0 in a vector of ints. #include <algorithm> #include <iterator> #include <vector> typedef std::vector<int> intvec; intvec values; // ... ints are added to values intvec::const_iterator split = std::find(values.begin(), values.end(), 0); Now I can use split to do things to the subranges begin() .. split and split .. end() . I want to do something similar, but with split