Hot answers tagged

6 votes

"ls" counterpart to "find" operator "-printf"?

Not with the GNU implementation of ls¹ as far as I know, however it's possible with some implementations of stat. For example stat from GNU Coreutils, stat --printf '%n\t%y\t%s\n' will give you the ...
steeldriver's user avatar
  • 79.6k
4 votes

Basename detects an extra operand if I use it with find

POSIX basename only supports this: basename string [suffix] What happens when providing more than two strings¹ is not specified by POSIX but in most if not all implementations results in a syntax ...
1 vote

find & cp command doesn't copy 1st level directory

-maxdepth 1 is a directive for find. Because of it your find will run cp … for ./1 and it won't run cp … for ./1/1-1; and so on. Note it will run cp … for . in the first place. When your find runs cp -...
Kamil Maciorowski's user avatar
1 vote

How do I correctly define and interpolate this variable into my find command?

This is because—since you are quoting the variable, as you should—it is passed aa single string to find. You can see this with set -x: $ all_exts=" -iname \"*.webm\" -o -iname \"*....
terdon's user avatar
  • 238k
1 vote

Pipe sql query to find command

Your find command looks in the current directory and downwards through any other subdirectories for a file (-type f) named /dev/stdin: find -type f -name /dev/stdin It doesn't read or use stdin at ...
Chris Davies's user avatar
1 vote

Slow down a `split`

Something like xargs -I {} ... mv {} aa is still going to run mv once per each line of input. From the POSIX specification of the -I option of xargs: Insert mode: utility is executed for each logical ...
muru's user avatar
  • 71.2k
1 vote

Is there any elegant way to find only symbolic links pointing to directories, not other files?

Disclaimer: I'm the current author of rawhide (rh) (see With rawhide (rh) you can do: rh 'l && td' Or, more verbosely/readably: rh 'link && ...
raf's user avatar
  • 161
1 vote

Delete all files without user permissions

Disclaimer: I'm the current author of rawhide (rh) (see With rawhide (rh) you can do: rh -UUU data 'f && !ur && !uw && !ux' -UUU unlinks/...
raf's user avatar
  • 161
1 vote

How can I find all of the directories that contain one or more files?

Simply, find movies -type f -print | \ xargs -r dirname | \ sort --uniq Read man find xargs dirname sort. Here's an explanation: find outputs a list of all the files, and their directories, ...
waltinator's user avatar
  • 4,709
1 vote

find command not working: "illegal option -- n"

I landed here when I googled for the same error message "illegal option -- n" I'm on MacOS, and my team are on Linux/Windows. Their version of find seems to be more permissive: The Broken ...
samjewell's user avatar
  • 111

Only top scored, non community-wiki answers of a minimum length are eligible