6
votes
Accepted
"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 ...
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 ...
Community wiki
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 -...
1
vote
Accepted
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 \"*....
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 ...
1
vote
Accepted
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 ...
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 https://github.com/raforg/rawhide)
With rawhide (rh) you can do:
rh 'l && td'
Or, more verbosely/readably:
rh 'link && ...
1
vote
Delete all files without user permissions
Disclaimer: I'm the current author of rawhide (rh) (see https://github.com/raforg/rawhide)
With rawhide (rh) you can do:
rh -UUU data 'f && !ur && !uw && !ux'
-UUU unlinks/...
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, ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
find × 3488bash × 649
linux × 446
shell × 366
shell-script × 365
grep × 361
files × 346
command-line × 200
xargs × 173
directory × 147
regular-expression × 137
sed × 132
ls × 131
rm × 123
filenames × 111
rename × 110
wildcards × 93
awk × 91
mv × 88
scripting × 86
macos × 75
recursive × 74
permissions × 72
cp × 71
pipe × 66