Skip to main content
copy not swap as per comments
Source Link
Sparhawk
  • 20.6k
  • 20
  • 97
  • 160

Swap Copy digits from end of string to another

How could I swapcopy digits from one end of a string to another end of a string? So example,

Input -

Example123:Hello Exp12:Hey1 Exp:heylo 

expected output -

Example123:Hello123 Exp12:Hey112 Exp:heylo 

I'm open to using sed or awk, seperator must be accounted for, so row1 is the row to extract digits from and row 2 is the row to place digits

Swap digits from end of string to another

How could I swap digits from one end of a string to another end of a string? So example,

Input -

Example123:Hello Exp12:Hey1 Exp:heylo 

expected output -

Example123:Hello123 Exp12:Hey112 Exp:heylo 

I'm open to using sed or awk, seperator must be accounted for, so row1 is the row to extract digits from and row 2 is the row to place digits

Copy digits from end of string to another

How could I copy digits from one end of a string to another end of a string? So example,

Input -

Example123:Hello Exp12:Hey1 Exp:heylo 

expected output -

Example123:Hello123 Exp12:Hey112 Exp:heylo 

I'm open to using sed or awk, seperator must be accounted for, so row1 is the row to extract digits from and row 2 is the row to place digits

edited tags
Source Link
Inian
  • 13.1k
  • 2
  • 42
  • 56

Bash - Swap digits from end of string to another

How could I swap digits from one end of a string to another end of a string?

  So example,

Input -

Example123:Hello Exp12:Hey1 Exp:heylo 

expected output -

Example123:Hello123 Exp12:Hey112 Exp:heylo 

I'm open to using sed or awk, seperator must be accounted for, so row1 is the row to extract digits from and row 2 is the row to place digits

Bash - Swap digits from end of string to another

How could I swap digits from one end of a string to another end of a string?

  So example,

Input -

Example123:Hello Exp12:Hey1 Exp:heylo 

expected output -

Example123:Hello123 Exp12:Hey112 Exp:heylo 

I'm open to using sed or awk, seperator must be accounted for, so row1 is the row to extract digits from and row 2 is the row to place digits

Swap digits from end of string to another

How could I swap digits from one end of a string to another end of a string? So example,

Input -

Example123:Hello Exp12:Hey1 Exp:heylo 

expected output -

Example123:Hello123 Exp12:Hey112 Exp:heylo 

I'm open to using sed or awk, seperator must be accounted for, so row1 is the row to extract digits from and row 2 is the row to place digits

Source Link

Bash - Swap digits from end of string to another

How could I swap digits from one end of a string to another end of a string?

So example,

Input -

Example123:Hello Exp12:Hey1 Exp:heylo 

expected output -

Example123:Hello123 Exp12:Hey112 Exp:heylo 

I'm open to using sed or awk, seperator must be accounted for, so row1 is the row to extract digits from and row 2 is the row to place digits