I would like to modify a particular line, say line 5, in a file by using the EOEX
construct how can I achieve my aim? The code snippet that I use to achieve my purpose is as follows:
#!/bin/bash
S=0.030
F=0.150
N=30
DIFF=`echo "scale=3; $F - $S" | bc -l`
dw=`echo "scale=3; $DIFF / $N" | bc -l`
is=`echo "scale=3; $S / $dw" | bc -l`
if=`echo "scale=3; $F / $dw" | bc -l`
ex ~/Desktop/Dropbox/MATLAB/FFT.m <<EOEX
:5s/for*/for i = $S:$dw:$F/g
:x
EOEX
I did some researh and learned that usually EOF
(end of file) is used in here scripts
for I/O
redirection to the standard input of a particular command(in my case it is ex
). I also learned that as long as the starting and finishing keywords are the same any word can be used instead of the EOF
. My problem is that instead of the desired effect which is replacing the line with another for loop
initializer in Matlab
this script does not delete the line and append the string at the end of the fifth line. For reference purposes I have also added my FFT.m file. I apologize for the inconvenience caused by the abstractedness of my question previously. Note that I am also open to using another program to achieve the desired effect but curious about why it cannot be achieved in ex
or vim
. Please click here for the Matlab script.
!
on edited line in normal mode.sed
?ex
scripts instead of EOF. It apparently stands for 'end of ex' instead of 'end of file'. Not sure the OP really knows though...