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

enter image description here

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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

jquery - ReferenceError: CKEDITOR is not defined -

android - Go back to previous fragment -