Issue
I have a script that I want to use to replace a small text with a larger one
This is what I was testing:
I want to make the text:
exit 0
for dev in `ls /dev | egrep "^[sh]d[[:alpha:]][[:digit:]]+$"`; do umount "/dev/"$dev &>/dev/null ; gio mount -u /media/*/* ; gio mount -u /media/$USER/* ; done
exit 0
Solution
One potential solution using 'pipe' as a delimiter and escaping some special characters:
sed 's|exit 0|ls /dev \|egrep "^[sh]d[[:alpha:]][[:digit:]]+$"|'
# Example
echo "some text; exit 0; more text" | sed 's|exit 0|ls /dev \|egrep "^[sh]d[[:alpha:]][[:digit:]]+$"|'
some text; ls /dev |egrep "^[sh]d[[:alpha:]][[:digit:]]+$"; more text
Answered By - jared_mamrot Answer Checked By - Mildred Charles (WPSolving Admin)