Skip to main content
added 63 characters in body
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 118
$ { IFS=, ; arr=( 1,54,54K,99k ); }

$ printf '%s\n' ${arr[@]}
1    
54    
54K    
99k

## note: enable extglobextended pattern matching for [...] with 'shopt -s extglob'
$ rearr=( "${arr[@]//%[Kk]/000}" )
$ printf '%s\n' ${rearr[@]}
1    
54    
54000    
99000

## or write the changes to same array
$ arr=( "${arr[@]//%[Kk]/000}" )

See also: How to add/remove an element to/from the array in bash?

$ { IFS=, ; arr=( 1,54,54K,99k ); }

$ printf '%s\n' ${arr[@]}
1    
54    
54K    
99k

## note: enable extglob for [...] with 'shopt -s extglob'
$ rearr=( "${arr[@]//%[Kk]/000}" )
$ printf '%s\n' ${rearr[@]}
1    
54    
54000    
99000

See also: How to add/remove an element to/from the array in bash?

$ { IFS=, ; arr=( 1,54,54K,99k ); }

$ printf '%s\n' ${arr[@]}
1    
54    
54K    
99k

## note: enable extended pattern matching for [...] with 'shopt -s extglob'
$ rearr=( "${arr[@]//%[Kk]/000}" )
$ printf '%s\n' ${rearr[@]}
1    
54    
54000    
99000

## or write the changes to same array
$ arr=( "${arr[@]//%[Kk]/000}" )

See also: How to add/remove an element to/from the array in bash?

added 63 characters in body
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 118
$ { IFS=, ; arr=( 1,54,54K,99k ); }

$ printf '%s\n' ${arr[@]}
1    
54    
54K    
99k

## note: enable extglob for [...] with 'shopt -s extglob'
$ rearr=( "${arr[@]//%[Kk]/000}" )
 
$ printf '%s\n' ${rearr[@]}
1    
54    
54000    
99000

See also: How to add/remove an element to/from the array in bash?

$ { IFS=, ; arr=( 1,54,54K,99k ); }

$ printf '%s\n' ${arr[@]}
1    
54    
54K    
99k

$ rearr=( "${arr[@]//%[Kk]/000}" )
 
$ printf '%s\n' ${rearr[@]}
1    
54    
54000    
99000

See also: How to add/remove an element to/from the array in bash?

$ { IFS=, ; arr=( 1,54,54K,99k ); }

$ printf '%s\n' ${arr[@]}
1    
54    
54K    
99k

## note: enable extglob for [...] with 'shopt -s extglob'
$ rearr=( "${arr[@]//%[Kk]/000}" )
$ printf '%s\n' ${rearr[@]}
1    
54    
54000    
99000

See also: How to add/remove an element to/from the array in bash?

added 64 characters in body
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 118
$ { IFS=, ; arr=( 1,54,54K,99k ); }

$ printf '%s\n' ${arr[@]}
1    
54    
54K    
99k

$ rearr=( "${arr[@]//%[Kk]/000}" )

$ printf '%s\n' ${rearr[@]}
1    
54    
54000    
99000

See also: How to add/remove an element to/from the array in bash?

$ { IFS=, ; arr=( 1,54,54K,99k ); }

$ printf '%s\n' ${arr[@]}
1    
54    
54K    
99k

$ rearr=( "${arr[@]//%[Kk]/000}" )

$ printf '%s\n' ${rearr[@]}
1    
54    
54000    
99000
$ { IFS=, ; arr=( 1,54,54K,99k ); }

$ printf '%s\n' ${arr[@]}
1    
54    
54K    
99k

$ rearr=( "${arr[@]//%[Kk]/000}" )

$ printf '%s\n' ${rearr[@]}
1    
54    
54000    
99000

See also: How to add/remove an element to/from the array in bash?

added 10 characters in body
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 118
Loading
Source Link
αғsнιη
  • 41.9k
  • 17
  • 75
  • 118
Loading