posix

Why does sh interpret these commands differently to zsh?

狂风中的少年 提交于 2020-12-07 16:42:04
问题 Context: I am trying to get the names of fonts installed on my Linux machine. The name is between two colons. When I run this script using zsh, it works. When I switch to sh it breaks. It probably deletes \n characters, because the output is all one line. cmd="$(fc-list)" names="$(echo $cmd | grep -oP "(?<=: ).*?(?=:)")" echo $names Which command causes the issues? Is it not POSIX compliant? 回答1: Why does sh interpret these commands differently to zsh? Because they are different shell the

Why does sh interpret these commands differently to zsh?

核能气质少年 提交于 2020-12-07 16:39:25
问题 Context: I am trying to get the names of fonts installed on my Linux machine. The name is between two colons. When I run this script using zsh, it works. When I switch to sh it breaks. It probably deletes \n characters, because the output is all one line. cmd="$(fc-list)" names="$(echo $cmd | grep -oP "(?<=: ).*?(?=:)")" echo $names Which command causes the issues? Is it not POSIX compliant? 回答1: Why does sh interpret these commands differently to zsh? Because they are different shell the

Is it possible to sync multiple clients over a central server using just rsync and POSIX shell scripting?

倾然丶 夕夏残阳落幕 提交于 2020-12-07 07:24:09
问题 The scenario I have a file server that acts as a master storage for the files to sync and I have several clients that have a local copy of the master storage. Each client may alter files from the master storage, add new ones or delete existing ones. I would like all of them to stay in sync as good as possible by regularly performing a sync operation, yet the only tool I have available everywhere for that is rsync and I can only run script code on the clients, not on the server. The problem