[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

`basename "$f"` and ${f##*/}



Hi everyone,

After reading /usr/share/initramfs-tools/hook-functions, I wanted to
comment that `basename "$foo"` is often replaced with the (posix)
shell expansion ${foo##*/} which expands to the value of foo with the
"longest prefix matching shell wildcard */ stripped" (but doesn't
modify foo).  There's also # for the shortest match, %% for the
longest suffix, and % for the shortest suffix.  I usually refer to
dash(1) for these things.

Justin



Reply to: