I wrote a script (replace.sh) that replaces a ~ with ~\n. I was wondering how can I call this script with multiple arguments.
#!/bin/bash
for i in "$*"
do
sed 's/~/~\n/g' "$i"
done
For example I would like to call ./replace.sh text1 text2. It cannot read
the contents of text1 are: 1 ~ 1 ~ 1. After calling the script it should be
1 ~
1 ~
1 ~
Use "$@"
in your for loop:
for i in "$@"
do
sed -i.bak 's/~/~\n/g' "$i"
done
Though I am not really sure if sed is doing what you've described here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With