I have to make a shift in some energy values, where the first entry of each file (num.xsf) is :
# total energy = -155.000000 eV
I made a little script to do this, and when I use it without the loop it works. The script:
# Change in -0.029
for file in *.xsf; do
        E=$(head -n 1 $file | cut -d " " -f 5)  #Filter E0
        E_c=$(echo "$E-0.029" | bc)             
        sed "s/$E/$E_c/1" $file > $file; done   # Replace num.xsf > num.xsf
        
I expect to have the same files but the energy line changed to: # total energy = -155.029000 eV, but this saves an empty file. how can I fix this?
 
    