1
lorentz
3y

I was passed someone else's homework which included describing what certain Bash commands do. I've a fair bit of experience and I can't imagine why this one would be useful, can you think of any use for it?

(find -type d) | grep public | tr './p' ' '

Comments
  • 0
    shield bash 🛡💥
  • 0
    Find directories called public, and rename to './p'

    or I'm looking at this all wrong and should get another coffee before punching that into a terminal and regretting every moment of it 😂
  • 1
    @C0D4 The tr command here replaces every occurence of any of the characters dot, slash and p with a space.
  • 1
    (find -type d)

    () For subshell.

    grep public

    search in result for public.

    Highly inefficient and fragile, as output of find is parsed directly.

    tr replaces chars as @Ibfalvy explained.

    All in all, total bleh.

    Note:

    ./public/test becomes ublic test

    The subshell is to dump all content before grep and tr takes place.

    Hence grep works on the whole output of the find command.
  • 0
    @IntrusionCM I know, my question was why this would ever be useful.
  • 0
    @lbfalvy

    Easier spotting of interesting substrings.

    I'd guess it's a way to "highlight" the substring.

    Maybe to find out which subfolders exists in an webserver directory to determine where the assets are stored.

    I'll do sometimes the same, just in a more eloquent way.

    Helps filtering out non interesting stuff. XD
Add Comment