From the Bash manual:
${parameter/pattern/string}
The pattern is expanded to produce a pattern just as in filename
expansion. Parameter is expanded and the longest match of pattern
against its value is replaced with string. The match is performed
according to the rules described below (see Pattern Matching). If
pattern begins with /
, all matches of pattern are replaced with string. ... If string is null, matches of pattern are deleted and the /
following pattern may be omitted.
You have ${line//[$'\r\n']}
, where:
- the parameter is
line
,
- the pattern is
/[$'\r\n']
(note: begins with /
, so all matches of pattern are replaced), and
- the string is null, so the
/
after pattern is omitted, and matches are deleted.
Following the rules for Pattern Matching:
[…]
Matches any one of the enclosed characters.
$'...'
tells bash to interpret certain escape sequences (here, \r
for carriage return and \n
for line feed) and replace them with actual characters represented by the escape sequences.
So this substitution matches all instances of either carriage return (CR, \r
) or line feed (LF, \n
), and deletes them.