#!/bin/bash
# author: Chiweiming
# version: v1
# date: 2024-03-26
<<COMMAND
檢查某個目錄下的所有檔案和目錄,看是否滿足下麵條件:
1)所有檔案許可權為 644
2)所有目錄許可權為 755
3)檔案和目錄所有者為 xxx,所屬組為 xxx
如果不滿足,改成符合要求
注意:不要直接修改許可權,一定要有判斷的過程
COMMAND
cd data
for file in $(find .)
do
f_p=$(stat -c %a "${file}")
f_u=$(stat -c %U "${file}")
f_g=$(stat -c %G "${file}")
if [[ -d ${file} ]]; then
[[ ${f_p} != '755' ]] && chmod 755 "${file}"
else
[[ ${f_p} != '644' ]] && chmod 644 "${file}"
fi
[[ ${f_u} != "chiweiming" ]] && chown chiweiming "${file}"
[[ ${f_g} != "chiweiming" ]] && chown :chiweiming "${file}"
done
shell practice 04
相關文章
- shell practice 03
- shell practice 05
- shell practice 06
- shell practice 07
- Linux深入探索04-Bash shellLinux
- Practice
- airflow practiceAI
- Shell程式設計-04-Shell中變數數值計算程式設計變數
- 04 shell程式設計之迴圈語句程式設計
- scientifically practice DP
- Practice| 流程控制
- 《前端運維》一、Linux基礎--04Shell變數前端運維Linux變數
- Shell階段04 shell流程之case語句, 服務啟動停止指令碼(rsync, nginx), shell加鎖機制指令碼Nginx
- Vegetables need more practice.
- yolov5s ncnn practiceYOLOCNN
- [#181024][PAT Practice] A+B FormatORM
- Shell程式設計基礎-04-一鍵安裝和配置程式設計
- Oracle 12.2 RAC on Linux Best Practice DocumentationOracleLinux
- SAP S4HANA LTMC Practice - the first shot!
- 1003 我要通過!| PAT (Basic Level) Practice
- Operating Systems: Principles and Practice 2nd ed. Edition
- The practice of high-performance graph computing system Plato in Nebula GraphORM
- PAT (Advanced Level) Practice 1149 Dangerous Goods Packaging (25分)Go
- Practice – iOS 專案持續整合實踐(一)iOS
- Practice - iOS 專案持續整合實踐(一)iOS
- 04--JS04--進階JS
- day04 -js04JS
- 04
- Shell:子shell概念
- GoCN 每日新聞 (2020-04-04)Go
- GoCN每日新聞(2019-04-04)Go
- PAT (Basic Level) Practice (中文)-1009-說反話 (20分)
- SDNU_ACM_ICPC_2021_Winter_Practice_4th [個人賽]ACM
- 04、MSTP
- java 04Java
- 04 Pinia
- shell——shell輸入輸出
- 打字大師3-盲打實踐:Master of Typing 3 - Practice for MacASTMac