I have a bash script that converts txt image with multi-lune to a single parameter which should be a single line because I need to pass it later as an argument to a different script.
the script removes the new lines "\n
" and put space instead-but What I need is to leave the "\n
" but still create a single line parameter.
original file (That is always changing and can have more/less lines), images.txt:
feeder-srv
newTag: develop_eaf7128
input-registry-srv
newTag: master_e16b788
shard-mongo-srv
newTag: master_2d2262e
shard-es-srv
newTag: master_66ac45e
Command to convert to one line parameter:
images_one_line=$(tr '\n' ' ' < images.txt)
parameter output is:
feeder-srv newTag: develop_eaf7128 input-registry-srv newTag: master_e16b788 shard-mongo-srv newTag: master_2d2262e shard-es-srv newTag: master_66ac45e
Which I later pass as argument to another script: source wiki-update.sh "${images_one_line}"
parameter output I need:
feeder-srv newTag: develop_eaf7128\n input-registry-srv newTag: master_e16b788\n shard-mongo-srv newTag: master_2d2262e\n shard-es-srv newTag: master_66ac45e\n
I need the "\n
" because I then using curl to perform a REST-API request to edit a page and I need to keep a certain HTML format:
` or ` – Tomalak Jun 07 '21 at 08:18