Assuming that I have in the folder :
MyFolder
the following files :
File1.txt File2.txt File3.txt File9.txt Bob.txt
I want to apply the following algorithm, but I don't know how to do it in Bash (actually the loop For is what I don't manage to do) :
For (each file of MyFolder directory)
add "<end>" at the end of the current text file
EndFor
What is the proper syntax in bash for that ?
Thank you in advance for your help.
This can make it:
In case you have some dirs inside, you may get the error
bash: XX: Is a directory. To avoid seeing them, you can add2>/dev/nullto the end of theechocommand:Or even better (thanks Barmar), check if they are files:
Which is a short way of doing an if-condition: