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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started