Tag Info

New answers tagged

0

rm -rf directory/ also works faster for billion of files in one folder. I tried that.


4

The problem is the whitespaces in your file name. Your new shell doesn't treat it as literal and interpreting it as separated files. You can using -print0 option with xargs command: find . -name "*.do*" -print0 | xargs -0 stat --printf='%n --- %y \n' or using -exec command with + instead of \;: find . -name "*.do*" -exec stat --printf='%n --- %y \n' {} ...


2

You need quoting for protecting the whitespace: find . -name "*.do*" -exec sh -c "stat --printf='%n --- %y \n' '{}'" \;


1

find doesn't have sophisticated options like ls. If you want ls -h, you need to call ls. find / -maxdepth 10 -size +100000 -exec ls -lh {} + I recommend the -xdev option to avoid recursing into other filesystems, which would be useless if you're concerned about disk space. find / -xdev -maxdepth 10 -size +100000 -exec ls -lh {} + If you use zsh as your ...


0

It isn't clear from the question if there is SSH access available to the server. If there is, I would simply use rsync for the job.


2

I don't think you need to use wget's recursive downloading options because you already have a list of the files that need downloading: wget --input-file=./path/to/your/list --base=URL In this way you would just follow the list in the first place, and so every file downloaded would be just the next in the list. So you could always find your progress by ...


2

You can do this with comm (using bash process substitution): comm -13 <(find / | sort) <(sort server_dump) This will show the files which are unique to the server. For files that are unique to the local system: comm -23 <(find / | sort) <(sort server_dump) You may also wan to add the -xdev option to find to stop it from comparing files on ...


0

Why not just dump the output of find to a file, on both hosts, and then do a diff on the two files? To get the number of files, you could count using wc.


1

I think what you are after is more like the following. find / -maxdepth 10 -size +100000 -exec ls -lah {} + The -exec allows you to execute a command and the {} is substituted with the result of the the find. Lastly the + is to tell find it is the end of the command and it is required.


2

The command you are trying is readable to me. However, you can make use of the file utility with the find as below. find / -maxdepth 10 -size +100000 -exec sh -c 'file -b {} | grep text &>/dev/null' \; -print Another way to do this is using the below command. du -BM / | sort -nr The above command will give you the files in the sorted file ...


0

if you happy with find ... -ls output format, then you may use: find ./ -mindepth 1 \( -type d -not -empty -ls \) , \( -type f -ls \) or you may use ... -printf "..." find ./ \( -type d -not -empty -printf "%s\t%p\n" \) , \( -type f -printf "\t%s\t%p\n" \) look find man page , search for -printf format , there lot of format directives.


2

You need to -exec a shell command instead: find . -name "*.txt" -exec sh -c 'tar cfj $(basename "{}" .txt).tb2 "{}"' -- {} \; Moreover, note that your find command is finding the files at all levels. As such, using basename to pass the list of files wouldn't work if the files do not exist in the current directory. To elaborate, tar cfj foo.tb2 foo.txt ...


0

Sample of fast(!) finding particular files (access_log) in multiple locations defined by wildcard (home directory) and general apache2 log directory applying also name filtering to exclude ssl logs and gzipped old logs. Does not directly answer the question here but might be userful for someone who found these instructions (like me). find / \( -path ...


5

Have you tried ? fc-list | grep -i "media" Also give a try to fc-scan, fc-match


14

The problem is, you didn't quote your -name parameter. Do this instead: find . -name '*.java' Explanation Without the quotes, the shell interprets *.java as a glob pattern and expands it to any file names matching the glob before passing it to find. This way, if you had, say, foo.java in the current directory, find's actual command line would be: find . ...


0

Why not use something like KDirStat Although it was originally written for KDE but it works fine with GNOME aswell It gives you best view of number of file/dir and respective usage in GUI


4

UPDATE: I did all of that below, which is cool, but I came up with a better way of sorting directories by inode use: du --inodes -S | sort -rh | sed -n \ '1,50{/^.\{71\}/s/^\(.\{30\}\).*\(.\{37\}\)$/\1...\2/;p}' And if you want to stay in the same filesystem you do: du --inodes -xS Here's some example output: 15K /usr/share/man/man3 4.0K ...


4

Using GNU tools: find / -xdev -type d -print0 | while IFS= read -d '' dir; do echo "$(find "$dir" -maxdepth 1 -print0 | grep -zc .) $dir" done | sort -rn | head -50 This uses two find commands. The first finds directories and pipes them to a while loop runs the next find for each directory. The second lists all the child files/directories in ...


1

find $DIR -depth -maxdepth 3 \ -type d -readable -printf \ 'printf "\\n%p\\n" ls -t --color=always "%p"\n' |\ . /dev/stdin 2>&- This avoids any argument list problems because the only argument ls will ever receive is the name of the directory you want listed. You can do this with anything you like. The shell just . sources the |pipe ...


1

To robustly list the filenames only using recent GNU tools: find . -printf '%A@ %p\0' | sort -nz | sed -z 's/^[^ ]* //' | tr '\0' '\n'


2

find -printf "%TY-%Tm-%Td %TT %p\n" | sort -n will give you something like 2014-03-31 04:10:54.8596422640 ./foo 2014-04-01 01:02:11.9635521720 ./bar


1

In bash, run shopt -s globstar first. In ksh93, run set -o globstar first. In zsh, you're already set. ls -dltr **/* This will return an error if you have so many files that the command line length limit on your system is exceeded. In zsh, you can use this instead: print -rl -- **/*(Om)


1

This one will list all files in <dir> with topmost being oldest modified find <dir> -type f -print0 | xargs -print0 ls -ltr And with this the latest modified is topmost find <dir> -type f -print0 | xargs -print ls -lt Note that this only works if the list of file names doesn't exceed the total command line length limit on your ...


0

When program is executed, it is the atime that is modified, not ctime or mtime. NOTE: use stat <filename> if you don't believe me. In order to check what file has been accessed between 2 defined dates, use -newer option in find Example : find ./ -name "*.class" -newerat "2014-03-01" ! -newerat "2014-04-02" Will display any file ending in .class ...


2

The closest you can come to finding when a file was last executed is by its atime rather than modification time - executing does not modify the files. However, there is no way to tell if the file was accessed for some other reason. Although, if a file hasn't been accessed within a specific time frame, then it can't have been executed. To list executable ...


1

You can use the following command to determine which of the files got modified in the recent time. ls -halt *.class In the above order, the first file in the output means, it was edited recently. If you want the output in the reverse order, ls -haltr *.class In the above output, the first file in the output means, it was edited long back. Once you ...


3

If you want to flatten the directory structure (thus sorting by date over all files in all directories, ignoring what directory the files are in) the find-approach suggested by @yeti is the way to go. If you want to preserve directory structure, you might try $ ls -ltR /path/to/directory which sorts directory based.


3

Assuming you are usuig GNU find, try: find $SOMEPATH -exec stat -c '%Y %n' '{}' + | sort -n


0

I am not sure, if I understand your question in its current form. If you don't care about a sub-directory with read access being placed in a directory without read access, then you can simply do: find . -type d -perm -u+r If you want to know, whether a specific user has read access to a directory, then get the group(s) she/he is a member of: groups ...


1

GNUly: find . -type f -name '*.pl' -size +0c -print0 > list && count=$(grep -cz . < list) && stdbuf -oL xargs < list -r0 sed -i -e '1{w /dev/stdout' -e 'd;}' | awk -v c="$count" '{printf "processed file %d/%d\r", NR, c} END{print ""}'


2

If you have bash 4, consider using globstar instead. It gives you recursive globbing. shopt -s globstar perlz=( **/*.pl ) # */ Hack to fix syntax highlighting totes="${#perlz[@]}" i=0 for file in "${perlz[@]}"; do printf 'Removing first line of Perl files … %d/%d\r' $((++i)) $totes ed -s "$file" <<< $'1d\nw' # You can use `sed` if you want ...


0

How about this? #!/bin/bash failed=0 find . -type f -name "*.pl" | while read file; do if [ -e "$file" ] && [ -r "$file" ]; then sed -i~ "1d" "$file" if [ $? != 0 ]; then echo "sed returns $? on ($file)" (( failed++ )) fi else echo "warning ($file) not exists, or not readable" (( failed++ )) fi ...


1

There are several problems: You confuse "${keywords[*]}" with "${keywords[@]}". The former expands to one argument. -q inhibits any output. If you have several patterns you cannot pass them as a list of arguments. You need -e pattern1 -e pattern2 instead. Or you must pass them in a file (see -f). I guess awk makes more sense in this case. This may be ...


1

Though I find your question highly suspect, the answer is: find ./ -type f -name '*.html' -printf "%Ta %p\n" | grep '^Mon' | sed 's:^Mon ::' Which will find all files ending in .html that were last modified on any Monday in human history, according to the current timezone set on the server.


1

You can use find + grep + date Command: find /path -iname "*.html" -printf "%TY%Tm%Td\t%p\n" | \ grep $(date -dlast-monday +%Y%m%d) if you want to print only file name then use: find /path -iname "*.html" -printf "%TY%Tm%Td\t%p\n" | \ awk "/$(date -dlast-monday +%Y%m%d)"'/{print $NF}' OR find /path -iname "*.html" -printf "%Ta\t%p\n" | awk ...


0

You can use find with stat to find all files that have a modification timestamp on a Monday as follows: find . -type f -exec stat -t %a {} \; | awk 'match($10, /"Mon"/) {print $16}' The find command will find all files and stat them which will be piped to the awk filter. awk will match field number 10 which is the modification time of file with string ...


4

I'm not sure of a good way to do this directly using only find or similar, but you can use find and grep: find -printf '%Tw:%h/%f\0' | grep -z '^1:' Since it's find, you can of course combine other flags: find -name '*.html' -type f -printf '%Tw:%h/%f\0' | grep -z '^1:' to get only files ending with .html. Explanation Here is my test directory: $ ls ...


1

You can get ls to output dates in a custom format ls --time-style=+%A *.html | grep " Monday " Assuming " Monday " is not in any file name.


1

I would just like point out this answer by @Gilles in Exclude paths that make find complain about permissions - Unix & Linux Stack Exchange; it basically involves a construct for find that makes it not descend unreadable directories, and in that sense, is probably also a bit faster. This would seem to work for me: With GNU find or any other find ...


2

The syntax you are using will find files older than 24 hours. For your current time of Fri Mar 21 16:10:42 UTC 2014, this would be files modified before Fri Mar 20 16:10:42 UTC 2014. However from your question it seems that you want files modified before Fri Mar 21 00:00:00 UTC 2014. The way to do this is to create a temporary file and change the ...


5

The find command will display the desired results if all of it's conditions are true. If not, the output will be unexpected, making it appear that it is not working. To find the files that are exactly 24 hours old, -mtime 1 is required. However, if there are no files meeting this condition, ls -lt will list all the files in the find path. Similarly, ...


4

To match repeating extensions, with zsh: rm -- *.*.*(e{'[[ $REPLY:t =~ "(\..*)\1$" ]]'}) Recursively: rm -- **/*.*.*(e{'[[ $REPLY:t =~ "(\..*)\1$" ]]'}) That would match a.php.php and b.x.x and c.x.y.x.y (and .php.php). With ksh93: rm -- *@(.*)\1 Recursively: set -o globstar rm -- **/*@(.*)\1 With GNU find, recursively: find . -regex ...


1

Try this at the root of your directory where you want to delete the files: find . -name "*.php.php*" -exec rm '{}' \;


4

rm -- *.php.php this will delete all files that have more than one php extension for all sub directories you need find /scripts/tmp -name "*.php.php" -exec rm {} + /scripts/tmp is the directory under which my files and subdirectories existed



Top 50 recent answers are included