Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • i haven't mentioned this explicitly, but it seems that my shell is not zsh but rather sh (hence i have only tagged this as shell - what's more, it seems i cannot actually change the shell (that's all within a flatpak build script). but IFS=:; find $PATH looks great. Commented Jul 30 at 14:16
  • @umläute: For interactive use I often use a subshell if I want to set IFS. Like (IFS=$'\n'; mpv $(locate -iA foo bar ) ) to play video/audio found by locate, with filenames from locate which don't contain newlines, but do contain spaces and whatnot. (Usually I control-r recall on $(locate, not retyping all of that from scratch. The actual command I use is mpv $(find $(locate ...) -maxdepth 0 -type f ...) to filter out dirs, so is a lot to type; I sometimes adjust parts other than the locate options so I've never bothered to put it in a script.) Commented Jul 31 at 10:03
  • 1
    @PeterCordes, note GNU find now supports a -files0-from predicate, so you can do (much more reliably and efficiently) find -files0-from <(locate -0 ...) -prune -type f -exec mpv {} + (or use zsh and its 0 parameter expansion flag to split NUL-delimited records (or f for line feed delimited records) and can filter lists of files by type with its glob qualifiers). Commented Jul 31 at 10:37
  • 1
    Wouldn't it be better to use ( IFS=:; find -H $PATH -name 'gcc-*' ) so the IFS value isn't changed in the parent shell? Commented Jul 31 at 11:30
  • 1
    @CSM, I don't know of any find implementation that supports a --depth=n option. FreeBSD's find has -depth 1, but it's a condition one only, doesn't stop from descending deeper, you want GNU-style -mindepth 1 -maxdepth 1 already mentioned. Commented Jul 31 at 14:54