【Linux】知って便利な一括操作コマンド

今回はxargsコマンドによる一括操作を紹介したいと思います。
あるフォルダ下のファイルを検索し、特定文字列があるところを出力
| 
					 1  | find /path/to/files -type f -print | xargs grep "search_string"  | 
あるフォルダ下のファイルを検索し、特定文字列を置換
| 
					 1  | find /path/to/files -name "*.sh" -print | xargs sed -i 's@string_before_replace@string_after_replace@g'  | 
※置換操作の前に、ファイルのバックアップを取ったほうがより安全でオススメです。
あるフォルダ下のファイルを検索し、子フォルダだけ権限変更
| 
					 1  | find /path/to/files -type d -print0 | xargs -0 chmod 777  | 
※findコマンドもある程度一括操作ができるようです。
Author Profile

スターフィールド編集部
SHARE




