a) Write a one-line sed command that will replace all multiple spaces in a file called names.txt (this is an arbitrary file that you may create yourself) by only one space.
b) Consider the following file called system.txt:
1 2 3 4
5 6 7 8
9 He 11 Hg
Ts H 15 Be
17 Mc Li 20
Write a one-line sed command that replaces the second number in every line with the string “system”, without the quotes. For example, after running the appropriate sed command, the following would be output to the terminal:
1 system 3 4
5 system 7 8
9 He system Hg
Ts H 15 Be
17 Mc Li system
c) 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
First question is :-
-----------------------------------
1.Write a one-line sed command that replace all multiple spaces in “name.txt” with only one space.
------------------------------------
Answer:-
------------------------------------
Suppose “names.txt” has the following content
-----------
Hi How Are You
------------
IF you observe the above content has multiple spaces.
-----------------------------------
Command--------------sed 's/ */\ /g' names
-----------------------------------
Output:-
Hi How Are You
=======================
Output images as follows:-
2. Second question is :-
-----------------------------------
1.Write a one-line sed command that replace second number in every line with the string “system”
------------------------------------
Answer:-
------------------------------------
Suppose “system.txt” has the following content
-----------
1 2 3 4
5 6 7 8
9 He 11 Hg
Ts H 15 Be
17 Mc Li 20
----------------------
Command--------------- sed -E 's/[0-9]+/system/2' system
----------------------
Output:-
1 system 3 4
5 system 7 8
9 He system Hg
Ts H 15 Be
17 Mc Li system
------------------------
Ouput Images as follows:-
For the better understand of 1st question i replace "double spaces" with "?" see below image
For the better understand of 2nd question i replace "second number in every line" with "hello" see below image
#please post a separate question for the remaining 2
parts
a) Write a one-line sed command that will replace all multiple spaces in a file called...
8. (4 pts + 2Xc) Write a bash shell script called 08-numMajors that will do the following i. Read data from a class enrollment file that will be specified on the command line ii. If the file does not exist, is a directory, or there are more or less than one parameters provided, display an appropriate error/usage message and exit gracefully Display the number of a specified major who are taking a given class iii. The following is a sample...
Create a program that will use the attached input file and perform the following operations. Read the file into an appropriate JCF data structure. Look up a (list of) names and numbers matching a last name or the first letters of a last name, ignoring case. Look up a (list of) names and numbers matching a number or the first digits of a number. Add a name and number to the list. Sort the list by first name, last name...