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.

5
  • 1
    ~ will be expanded (at the time of that assignment) if you run PATH=~/bin:$PATH. The OP must have run something like PATH='~/bin':$PATH. Commented Apr 11, 2024 at 14:53
  • I had export PATH="~/bin:$PATH" in ~/.bashrc. After fixing it to export PATH="$HOME/bin:$PATH" command find `echo $PATH | tr ':' ' '` -lname /opt/openoffice4/program/soffice started working without showing error. (IFS=:; find $PATH -lname /opt/openoffice4/program/soffice) is also working. Thanks! Commented Apr 11, 2024 at 18:05
  • @StéphaneChazelas with PATH=~/bin:$PATH also everything is fine, but I think it is better to use quotes around $PATH like export PATH=~/bin:"$PATH" for case if $PATH contains or will contain spaces. Commented Apr 11, 2024 at 18:11
  • 2
    @AntonSamokat, we quote expansions to prevent the splitting and globbing that happens otherwise in list contexts. Note that the splitting part is not on "spaces" but on characters of $IFS (which only happens to contain space by default). A scalar variable assignment is not one of those list contexts. PATH=~/bin:$PATH is a scalar variable assignment. And in bash, in export PATH=~/bin:$PATH the argument to export is also treated as a scalar assignment, so there won't be any split+glob. $PATH is already exported though so the export is superfluous. Quoting $PATH won't harm. ~ does Commented Apr 11, 2024 at 20:13
  • @StéphaneChazelas I've found related question about this: Expansion of a shell variable and effect of glob and split on it Commented Apr 13, 2024 at 17:33