I have the directories structure as below:
Folder1/
|____file.txt
Folder2/
|____file.txt
Folder3/
|____file.txt
:
Foldern/
|____file.txt
Each .txt file in the directories has a word that I want to replace with the directory name.
file.txt:
"name": "Engineering",
I am looking to replace the word Engineering with the directory name, e.g. for Folder1:
"name": "Folder1"
My intial attempt is as below:
for f in Folder*; do (cd $f; echo $f; sed -i -e "s/Engineering/Folder*/" file.txt); done
However, the sed command doesn't seem to see Folder* as Folder numbers.
jqrather thansedmay be preferable (if one know anything about the structure of those JSON files).