Loop over files - bash one line

It’s simple:

for i in *; do echo $i; done

If you want to replace a certain text in all files with something new, use this:

for i in *; do sed -i 's/original/new/g' $i; done

where original is the original text and new is the new text. If you run the following script…

for i in *; do sed -i 's/foo/bar/g' $i; done

…in a folder, which contains a file with the content:

Hello foo, my name is bar

the result will be:

Hello bar, my name is bar