find

Error: “grep: Argument list too long” [duplicate]

随声附和 提交于 2020-01-22 07:36:24
问题 This question already has answers here : How can I grep while avoiding 'Too many arguments' [duplicate] (5 answers) Closed 4 years ago . I am trying to run the following command, but gets argument too long error. Can you help?. HOST# grep -rl 'pattern' /home/*/public_html/* -bash: /bin/grep: Argument list too long Is there a way to override this error and grep the pattern matching files I want in all users public_html directory. There are around 500+ users in the same server. 回答1: Use find

Linux Command Line using for loop and formatting results

风流意气都作罢 提交于 2020-01-21 15:42:56
问题 How can I use one command line to provide a list of all files between a certain size and then format the file with name, md5 has and the file size. The example output should be file1.*** MD5 value size file2.*** MD5 value size etc. Ive tried the following but it displays the md5 on a separate line find 'directory' -size +30000c -size -50000c | while read filename do ls -l "$filename" | awk '{print $9 "\t" $5}' md5sum "$filename" | awk '{print $1}' done It outputs the follow with the MD5 on a

Linux Command Line using for loop and formatting results

走远了吗. 提交于 2020-01-21 15:41:33
问题 How can I use one command line to provide a list of all files between a certain size and then format the file with name, md5 has and the file size. The example output should be file1.*** MD5 value size file2.*** MD5 value size etc. Ive tried the following but it displays the md5 on a separate line find 'directory' -size +30000c -size -50000c | while read filename do ls -l "$filename" | awk '{print $9 "\t" $5}' md5sum "$filename" | awk '{print $1}' done It outputs the follow with the MD5 on a

bash find, only delete files - order of arguments

人走茶凉 提交于 2020-01-21 14:22:05
问题 Say today is April 8th and I execute the following in bash. cd /tmp mkdir hello touch -d 2015-04-01 hello Then, say I want to delete all files in /tmp that are older than one day, but NOT directories and I execute this: find /tmp -mtime +1 -delete -type f Why is directory "hello" deleted if it's not a file? Thanks! 回答1: The find command executes the expression in order. Since -delete is before -type , -type is never reached. Try: find /tmp -mtime +1 -type f -delete 回答2: David C. Rankin's

bash find, only delete files - order of arguments

孤街醉人 提交于 2020-01-21 14:21:56
问题 Say today is April 8th and I execute the following in bash. cd /tmp mkdir hello touch -d 2015-04-01 hello Then, say I want to delete all files in /tmp that are older than one day, but NOT directories and I execute this: find /tmp -mtime +1 -delete -type f Why is directory "hello" deleted if it's not a file? Thanks! 回答1: The find command executes the expression in order. Since -delete is before -type , -type is never reached. Try: find /tmp -mtime +1 -type f -delete 回答2: David C. Rankin's

bash find, only delete files - order of arguments

霸气de小男生 提交于 2020-01-21 14:20:28
问题 Say today is April 8th and I execute the following in bash. cd /tmp mkdir hello touch -d 2015-04-01 hello Then, say I want to delete all files in /tmp that are older than one day, but NOT directories and I execute this: find /tmp -mtime +1 -delete -type f Why is directory "hello" deleted if it's not a file? Thanks! 回答1: The find command executes the expression in order. Since -delete is before -type , -type is never reached. Try: find /tmp -mtime +1 -type f -delete 回答2: David C. Rankin's

How to sort 'find' results in bash by size

南笙酒味 提交于 2020-01-21 12:24:27
问题 I am wondering if there's an "easy" way (through a pipe or something) to order (by file size) the results of a "find" command in bash such as: find /location/of/directory/ -type f -size +2G 回答1: You can use %k for example to print the size in kilobytes: find . -type f -size +2G -printf "%kKB %p\n" | sort -n By saying -printf "%kKB %p\n" you are printing the file in kilobytes and then the name. sort -n gets this input and sorts it accordingly. See an example: $ find . -type f -size +1M -printf

How to find index of an exact word in a string in Python

五迷三道 提交于 2020-01-20 05:48:45
问题 word = 'laugh' string = 'This is laughing laugh' index = string.find ( word ) index is 8, should be 17. I looked around hard, but could not find an answer. 回答1: You should use regex (with word boundary) as str.find returns the first occurrence. Then use the start attribute of the match object to get the starting index. import re string = 'This is laughing laugh' a = re.search(r'\b(laugh)\b', string) print(a.start()) >> 17 You can find more info on how it works here. 回答2: try this: word =

how using SQL IN operator in find method of cakephp ORM

六眼飞鱼酱① 提交于 2020-01-20 04:02:28
问题 i am beginner in cakephp , and i want use SQL IN operator in find method , i have words table. my code is : $this->Word->find('Word.wordid in (83,82)'); , and this code create this query : SELECT `Userword`.`userwordid`, `Userword`.`userid`, `Userword`.`wordid`, `Userword`.`date`, `Userword`.`levelid` FROM `userwords` AS `Userword` WHERE `Userword`.`wordid` = (82) but i need this query SELECT `Userword`.`userwordid`, `Userword`.`userid`, `Userword`.`wordid`, Userword`.`date`, `Userword`.

How can I find files that only have certain permission for owner?

江枫思渺然 提交于 2020-01-19 23:54:41
问题 I would like to find files only by a certain user's permission. For example, if I want to find a file that I have full permission. I may do something like: find . -user $(whoami) -perm But what should I put after -perm if I want to ignore the permission of root and other users. 回答1: Start with: find /path/to/file -user user1 -perm -u+rwx This means: look for files starting in /path/to/files , owned by user1 , where the permissions for group and other can be anything (- in front of permission