25 To delete the last word of each line in the file test1
-
1 sed 's/ */$//' test1
-
2 sed 's/ *$//' test1
-
3 sed 's/ \*$//' test1
-
4 sed 's/ \*$\/\/' test1
B
Correct answer
Explanation
The sed command 's/ *$//' removes trailing spaces from each line. The pattern ' *$' matches zero or more spaces ($) at the end of a line. This will delete the last word if words are space-separated and the line has no trailing punctuation. Option A targets the beginning, C targets literal asterisks, and D has incorrect escaping.