To delete the last word of each line in the file test1
-
sed 's/ */$//' test1
-
sed 's/ *$//' test1
-
sed 's/ \*$//' test1
-
sed 's/ \*$\/\/' test1
B
Correct answer
Explanation
The sed command 's/ *$//' removes trailing spaces from each line - it matches zero or more spaces at the end of the line and replaces them with nothing. The $ anchor matches the end of line, and * matches zero or more spaces. This effectively strips trailing whitespace.