find

Finding human-readable files on unix

本小妞迷上赌 提交于 2019-12-31 16:30:04
问题 I'd like to find human-readable files on my linux machine without a file extension constraint. Those files should be of human sensing files like text, configuration, html, source-code etc. files. Could you suggest a way to filter and locate. 回答1: find and file are your friends here: find /dir/to/search -type f -exec sh -c 'file -b {} | grep text &>/dev/null' \; -print this will find any files ( NOTE: it will not find symlinks directories sockets etc only regular files ) in /dir/to/search and

Finding human-readable files on unix

微笑、不失礼 提交于 2019-12-31 16:29:07
问题 I'd like to find human-readable files on my linux machine without a file extension constraint. Those files should be of human sensing files like text, configuration, html, source-code etc. files. Could you suggest a way to filter and locate. 回答1: find and file are your friends here: find /dir/to/search -type f -exec sh -c 'file -b {} | grep text &>/dev/null' \; -print this will find any files ( NOTE: it will not find symlinks directories sockets etc only regular files ) in /dir/to/search and

Find count of files matching a pattern in a directory in linux

大憨熊 提交于 2019-12-31 13:15:15
问题 I am new to linux. I have a directory in linux with approx 250,000 files I need to find count of number of files matching a pattern. I tried using following command : ls -1 20061101-20131101_kh5x7tte9n_2010_* | wc -l I got the following error message: -bash: /bin/ls: Argument list too long 0 Please help. Thanks in advance 回答1: It might be better to use find for this: find . -name "pattern_*" -printf '.' | wc -l In your specific case: find . -maxdepth 1 -name "20061101-20131101_kh5x7tte9n_2010

How do I form a good predicate delegate to Find() something in my List<T>?

早过忘川 提交于 2019-12-31 08:13:32
问题 After looking on MSDN, it's still unclear to me how I should form a proper predicate to use the Find() method in List using a member variable of T (where T is a class) For example: public class Car { public string Make; public string Model; public int Year; } { // somewhere in my code List<Car> carList = new List<Car>(); // ... code to add Cars ... Car myCar = new Car(); // Find the first of each car made between 1980 and 2000 for (int x = 1980; x < 2000; x++) { myCar = carList.Find(byYear(x)

How do I form a good predicate delegate to Find() something in my List<T>?

*爱你&永不变心* 提交于 2019-12-31 08:13:03
问题 After looking on MSDN, it's still unclear to me how I should form a proper predicate to use the Find() method in List using a member variable of T (where T is a class) For example: public class Car { public string Make; public string Model; public int Year; } { // somewhere in my code List<Car> carList = new List<Car>(); // ... code to add Cars ... Car myCar = new Car(); // Find the first of each car made between 1980 and 2000 for (int x = 1980; x < 2000; x++) { myCar = carList.Find(byYear(x)

Bash script delete files older than n days ago based on the timestamp in filename? [duplicate]

筅森魡賤 提交于 2019-12-31 05:43:33
问题 This question already has answers here : Delete all files older than 30 days, based on file name as date (2 answers) Closed last month . I have some logs files with somefiles.log.YYYY-mm-dd and I want to delete those files that are older than N days base on the timestamp in its filename. 回答1: use cut command to retrieve YYYY-MM-dd part of filename. and use date command as following to convert it to time_t type. date -d "YYYY-MM-dd" +%s then you can compare time_t to determine which file

Java execute command line program 'find' returns error

冷暖自知 提交于 2019-12-30 20:26:10
问题 The following works from the terminal no problem find testDir -type f -exec md5sum {} \; Where testDir is a directory that contains some files (for example file1, file2 and file3). However, I get an error using the following in Java Runtime rt = Runtime.getRuntime(); Process pr = rt.exec("find testDir -type f -exec md5sum {} \\;"); The error is find: missing argument to `-exec' I believe I am escaping the characters correctly. I have tried several different formats and I cannot get this to

Find files containing multiple strings

纵饮孤独 提交于 2019-12-30 11:23:32
问题 I use a command to recursively find files containing a certain string1 : find . -type f -exec grep -H string1 {} \; I need to find files containing multiple strings, so the command should return those containing all strings. Something like this: find . -type f -exec grep -H string1 AND string2 {} \; I couldn't find a way. The strings can be anywhere in the files. Even a solution for only two strings would be nice. 回答1: you can also try this; find . -type f -exec grep -l 'string1' {} \; |

mongodb: finding the highest numeric value of a column

非 Y 不嫁゛ 提交于 2019-12-30 08:50:25
问题 I have MongoDB collection of documents containing several fields. One of the columns/fields should be numeric only, but some of these fields contain non-numerical (corrupt) data as string values. I should find the highest numerical value of this column, excluding the corrupt, non-numerical data. I am aware of the question Getting the highest value of a column in MongoDB, but AFAIK, this extended case was not covered. The example below depicts the issue. For the highest value, the document

Find object in array with subarray checking an property

青春壹個敷衍的年華 提交于 2019-12-30 07:51:12
问题 I have the array below and each element has another array called FunctionalityChildren, I need find the unique object that contains the property ActionFull equal a variable, for example '/budget/allocation' or '/budget' let bigArray = [ { "FunctionalityID": 114, "Name": "General Register", "Action": "/general-register", "Icon": "settings_input_composite", "System_ID": 21, "FunctionalityFather_ID": null, "Active": 1, "Priority": 1, "FunctionalityChildren": [ { "FunctionalityID": 115, "Name":