I want to copy multiple lines from a file to a shell script (i.e. not an "ordinary" file).
For example:
- source file
A.txt
'ab cd' 'ef gh' 'ij kl'
- target script file
script.sh
.... .... list=( HERE I NEED TO COPY AND PASTE THE CONTENT FROM a.TXT file. )
- The result should look like this:
.... .... list=( 'ab cd' 'ef gh' 'ij kl' )
The shell script should copy and paste automatically the content from another file to a script file. Kindly help me to resolve this
script.sh
to modify the filescript.sh
? As a shell script is basically text, this task is not different from modifying other text files. Do you expect the change to have an effect on the execution of the script? The latter is normally not the case unless you somehow re-run the script. How exactly should the script determine where to put the contents ofA.txt
? Replace every line that containsHERE I NEED TO COPY AND PASTE THE CONTENT FROM a.TXT file.
with the contents of the file?A.txt
contains anything but nicely quoted lines). It would be trivial to write the script in such a way that it reads the contents ofA.txt
into the arraylist
usingreadarray -t list <A.txt
, provided you were usingbash
.