do you know why in this command, $x is visible
ls -d */ $1 | while read x; do echo $x; done
return the sub directories in the current directory.
However, when I put in another command, $x seems to have no value
ls -d */ $1 | while read x; do ls -lat /order | grep $x; done
return nothing
/orderdirectory, which is not self-evidently related to*/or$1. Did you mean to use something else in place of/order?/order/123? Or a file in/orderwith123in any of the characteristics shown byls -lat? (length including digits 123, mainly). If not, the grep won't find anything.|separates commands that are run in their own separate subshells. You cannot split a loop across two separate processes.