Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
fixed formatting (use <code>)
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

I need to write a shell script where I have to create a duplicate record based on a condition and then change the value in a column of the new row which will be created.

I am trying to create a duplicate record based on a condition and then replace on column in the duplicate row.

Example:

Input will be

Col1,Col2,Col3,Col4,COl5

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR

If the last column ie; col5 is EUR, then one more row should be created with change in column value.

Output should be

Col1,Col2,Col3,Col4,Col5

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR
3456,abcd,abcd,wxyz,AUD

Please help me with this.

I need to write a shell script where I have to create a duplicate record based on a condition and then change the value in a column of the new row which will be created.

I am trying to create a duplicate record based on a condition and then replace on column in the duplicate row.

Example:

Input will be

Col1,Col2,Col3,Col4,COl5

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR

If the last column ie; col5 is EUR, then one more row should be created with change in column value.

Output should be

Col1,Col2,Col3,Col4,Col5

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR
3456,abcd,abcd,wxyz,AUD

Please help me with this.

I need to write a shell script where I have to create a duplicate record based on a condition and then change the value in a column of the new row which will be created.

I am trying to create a duplicate record based on a condition and then replace on column in the duplicate row.

Example:

Input will be

Col1,Col2,Col3,Col4,COl5

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR

If the last column ie; col5 is EUR, then one more row should be created with change in column value.

Output should be

Col1,Col2,Col3,Col4,Col5

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR
3456,abcd,abcd,wxyz,AUD

I need to write a shell script where I have to create a duplicate record based on a condition and then change the value in a column of the new row which will be created.

I am trying to create a duplicate record based on a condition and then replace on column in the duplicate row.

Example:

Input will be

Col1,Col2,Col3,Col4,COl5

1234,abcd,abcd,wxyz,USD

2345,abcd,abcd,wxyz,USD

3456,abcd,abcd,wxyz,EUR

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR

If the last column ie; col5 is EUR, then one more row should be created with change in column value.

Output should be

Col1,Col2,Col3,Col4,Col5

1234,abcd,abcd,wxyz,USD

2345,abcd,abcd,wxyz,USD

3456,abcd,abcd,wxyz,EUR

3456,abcd,abcd,wxyz,AUD

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR
3456,abcd,abcd,wxyz,AUD

Please help me with this.

I need to write a shell script where I have to create a duplicate record based on a condition and then change the value in a column of the new row which will be created.

I am trying to create a duplicate record based on a condition and then replace on column in the duplicate row.

Example:

Input will be

Col1,Col2,Col3,Col4,COl5

1234,abcd,abcd,wxyz,USD

2345,abcd,abcd,wxyz,USD

3456,abcd,abcd,wxyz,EUR

If the last column ie; col5 is EUR, then one more row should be created with change in column value.

Output should be

Col1,Col2,Col3,Col4,Col5

1234,abcd,abcd,wxyz,USD

2345,abcd,abcd,wxyz,USD

3456,abcd,abcd,wxyz,EUR

3456,abcd,abcd,wxyz,AUD

Please help me with this.

I need to write a shell script where I have to create a duplicate record based on a condition and then change the value in a column of the new row which will be created.

I am trying to create a duplicate record based on a condition and then replace on column in the duplicate row.

Example:

Input will be

Col1,Col2,Col3,Col4,COl5

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR

If the last column ie; col5 is EUR, then one more row should be created with change in column value.

Output should be

Col1,Col2,Col3,Col4,Col5

1234,abcd,abcd,wxyz,USD
2345,abcd,abcd,wxyz,USD
3456,abcd,abcd,wxyz,EUR
3456,abcd,abcd,wxyz,AUD

Please help me with this.

Source Link
Rakesh K
  • 151
  • 1
  • 2
  • 10
Loading