[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: String replacement drops leading '-e' if replacing char is a space
From: |
Eduardo Bustamante |
Subject: |
Re: String replacement drops leading '-e' if replacing char is a space |
Date: |
Sun, 13 Aug 2023 22:27:15 -0700 |
>
> Description:
>
> If a string starts with '-e' the replacement operators ${x//,/ } and ${x/,
> /} drop the '-e'.
> The behaviour seems to be very specific: the string must start with '-e'
> and the replacing character has to be a space.
>
> Repeat-By:
>
> x='-e,b,c'
> echo ${x//,/ }
> b c
> echo ${x/,/ }
> b,c
>
The echo command is consuming the '-e', as it is a flag. Instead, try
using:
printf '%s\n' "${x/,/ }"