I have a problem with changing file content using sed. Let me describe what I would like to do.
I have a few text files in one folder:
123.txt
456.txt
789.txt
If you open them, each of those text files will have such a text at the top line:
Blablabla
What I would like to do is using while and sed commands to replace Blablabla with the file name without extension and that's how I wanted to do it:
for files in ./*.txt; do
while ! [[ $(grep "${files%.*}" ./"${files##*/}") ]]; do
table_name="${files%.*}"
sed -i 's/Blablabla/$table_name/g' ./"${files##*/}"
done
done
Unfortunately it doesn't work. Could anyone help me with that?
Thanks in advance!