มีวิธีการคัดลอกไฟล์ README.txt จาก / root ในทุก / home / {USER} / public_html dir โดยใช้ CLI หรือไม่
มีวิธีการคัดลอกไฟล์ README.txt จาก / root ในทุก / home / {USER} / public_html dir โดยใช้ CLI หรือไม่
คำตอบ:
ใช้ (สมมติว่าทุบตี):
pushd /home;
for file in ./*; do
cp /root/README.txt /home/$file/public_html/
chown $file /home/$file/public_html/README.txt
# this is a cheat, assuming that every user's name equals his home directory
done;
popd
อิสระเชลล์คุณสามารถใช้ "ค้นหา" ใน ...
find /home -name public_html -maxdepth 2 -exec cp /root/README.html {} \;