bash - Edit all the similar files in subdirectories in linux in one shot -
i have directory structure shown in image below. can there script written in linux traverses under sub directories , adds line of text in beginning of file having extension .txt
there multiple folders have file having extension .txt
find root -type f -name '*.txt' -exec sed -i '1i\ line insert ' {} + the find command recurse root directory, looking filenames match *.txt. execute sed command, inserts line @ beginning of file.

Comments
Post a Comment