Timeline for How to find files with find tool in system path ($PATH)? Or alternatively, How to specify starting-point directory for find as an expression?
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 13, 2024 at 17:33 | comment | added | Anton Samokat | @StéphaneChazelas I've found related question about this: Expansion of a shell variable and effect of glob and split on it | |
| Apr 11, 2024 at 20:13 | comment | added | Stéphane Chazelas |
@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
|
|
| Apr 11, 2024 at 18:12 | vote | accept | Anton Samokat | ||
| Apr 11, 2024 at 18:11 | comment | added | Anton Samokat |
@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.
|
|
| Apr 11, 2024 at 18:05 | comment | added | Anton Samokat |
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!
|
|
| Apr 11, 2024 at 14:53 | comment | added | Stéphane Chazelas |
~ 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.
|
|
| Apr 11, 2024 at 14:44 | history | answered | Chris Davies | CC BY-SA 4.0 |