Question: using sed Consider the following file called swap.txt : 349 230 481 800 456 129 043 942 584 901 627 874 Each three-digit number is

using sed

Consider the following file called swap.txt:

349 230 481

800 456 129

043 942 584

901 627 874

Each three-digit number is separated by a space. Write a one-line sed command that performs in-place substitution to swap the first digit with the third digit of the first number in every line. For example, after running the appropriate sed command, the swap.txt file would contain:

943 230 481

008 456 129

340 942 584

109 627 874

For bonus, can you swap the first digit with the third digit of the second number in every line? Do not worry about performing in-place substitution for this part. For example, after running the appropriate sed command, the following would be output to the terminal:

349 032 481

800 654 129

043 249 584

901 726 874

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!