From f7f2b995ea8b2ab83135971924f274c5fc62cad3 Mon Sep 17 00:00:00 2001 From: tiyn Date: Thu, 2 Oct 2025 01:57:37 +0200 Subject: [PATCH] linux/shell: added recursive replacement --- wiki/linux/shell.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wiki/linux/shell.md b/wiki/linux/shell.md index 01fd8ae..dbdfb35 100644 --- a/wiki/linux/shell.md +++ b/wiki/linux/shell.md @@ -210,6 +210,17 @@ cd ../"$(ls -F .. | grep '/' | grep -B1 -xF "${PWD##*/}/" | head -n 1)" cd ../"$(ls -F .. | grep '/' | grep -A1 -xF "${PWD##*/}/" | tail -n 1)" ``` +### Replacing All Occurences in a Directory + +To all occurences of a given string for all files recursively in a given directory run the +following command, where `` is the directory to replace in. +`` is the string to replace and `` is the string it should replaced with; both +of these may be escaped if special signs are contained in them. + +```sh +find -type f -exec sed -i "s///g" {} \; +``` + ## Error solving This section addresses various problems that can occur and are related to the shell.