Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

sed replace single line with multi line

wget -O metallb-values.yml https://raw.githubusercontent.com/bitnami/charts/master/bitnami/metallb/values.yaml
cat > /tmp/0 <<EOF 
configInline:
  # The address-pools section lists the IP addresses that MetalLB is
  # allowed to allocate, along with settings for how to advertise
  # those addresses over BGP once assigned. You can have as many
  # address pools as you want.
  address-pools:
  - # A name for the address pool. Services can request allocation
    # from a specific address pool using this name, by listing this
    # name under the 'metallb.universe.tf/address-pool' annotation.
    name: generic-cluster-pool
    # Protocol can be used to select how the announcement is done.
    # Supported values are bgp and layer2.
    protocol: layer2
    # A list of IP address ranges over which MetalLB has
    # authority. You can list multiple ranges in a single pool, they
    # will all share the same settings. Each range can be either a
    # CIDR prefix, or an explicit start-end range of IPs.
    addresses:
    - 192.xxx.xxx.xx1-192.xxx.xxx.xx5
EOF
sed -i -e "/configInline: {}/r /tmp/0" -e "//d" metallb-values.yml
Comment

sed replace single line with multi line

echo ${DATA} > temp.txt    
sed -i -e "/_data_/r temp.txt" -e "//d" mail.tpl
Comment

sed replace single line with multi line

$ echo test | sed 's/test/line
> line'
line
line
Comment

sed replace single line with multi line

DATA="$(cat whatever)"
ESCAPED_DATA="$(echo "${DATA}" | sed ':a;N;$!ba;s/
/
/g' | sed 's/$/$/g')"

Then you can use ${ESCAPED_DATA} in sed:

cat input | sed 's/one liner/'"${ESCAPED_DATA}"'/' > output 
Comment

sed replace single line with multi line

DATA="a
b
c"

ESCAPED=$(echo "${DATA}" | sed '$!s@$@@g')
echo "${ESCAPED}" 
a
b
c

sed "s/pattern/${ESCAPED}/" file
Comment

PREVIOUS NEXT
Code Example
Shell :: how to find files and copy them in terminal 
Shell :: eslint --fix 
Shell :: mac run a shell script 
Shell :: how to install centos 9 stream 
Shell :: du kan fixa tillbaka det med hjälp av GIT 
Shell :: how to append linux to exists flutter project 
Shell :: shell access 
Shell :: remove directory in linux 
Shell :: install burp suite kali 
Shell :: to run index.html using parcel server 
Shell :: parar serviço na porta 
Shell :: add quotes to column and replace with comma 
Shell :: passing variables into array 
Shell :: preserve bash history 
Shell :: Unset a Variable; Remove Variable; Delete Variable 
Shell :: debug chrome remote ssh 
Shell :: how to copy all branch commits to a whole new branch 
Shell :: systemd wait for service to finish before login 
Shell :: +dh_dwz returned exit code 1 
Shell :: Instala o Prettier no desenvolvimento 
Shell :: switch directory when activating environment 
Shell :: linux pass a programm to background 
Shell :: install media library 
Shell :: forward parameters batch script 
Shell :: shell startup file 
Shell :: create fake json from terminal 
Shell :: git diff without pagination 
Shell :: unzip start of central directory not found 
Shell :: where to export wsl AppData 
Shell :: mention profile sls deploy 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =