-
การไม่อนุญาติให้ดู file listing ใน folder
Posted on August 23rd, 2013 No comments1. ทำการสร้า่ง index.html แบบว่างเปล่าไว้ในแต่ละ directory ที่ไม่ต้องการให้ listing ได้
2. ถ้าจะทำหลาย folder อาจใช้วิธีเขียน script ง่าย ๆ ดังนี้
anan:~$ ls
anan:~$ 01 02 03 04 <— สมมติว่ามี 4 folderanan:~$ Temp=`ls` <— สร้างตัวแปล Temp เพื่อเก็บค่าที่ได้จากการใช้คำสั่ง ls (ระวังใช้ตัว back quote `)
anan:~$ echo Temp
anan:~$ 01 02 03 04 <—- จะเห็นค่าตัวแปร Temp เป็นชื่อ folder ทั้งหมดanan:~$ for x in $Temp <—- สร้าง for loop ใช้ตัวแปรชั่วคราวชื่อ x
> do
> touch $x/index.html <—– ทำการสร้าง file ชื่อ index.html แบบว่างเปล่าขึ้นมาโดยใช้คำสั่ง touch
> done
anan:~$ถ้าเข้าไปดูแต่ละ folder ก็จะพบ file ชื่อ index.html
anan:~$ cd 01
anan:~/01$ abc def a111 index.html(ขอขอบคุณ อ.ดร.อภิรักษ์ จันทร์สร้าง ที่แนะนำเทคนิคนี้)