POSIX Shell Programming Challenge - Programming On Unix
Users browsing this thread: 1 Guest(s)
|
|||
Another challenge, if you don't mind.
What's the best way to replace a $HOME prefix in a path (say, $PWD) with "~"? For example, replace "/home/phill/tmp" with "~/tmp" I tried this: Code: $ echo "$PWD" | sed "s,^$HOME,~," But since we are considering the worst scenarios in this thread, what if $HOME contains a comma? Is there any POSIX shell failproof solution? |
|||