FUNDAMENTALS OF COMPUTER

COMPUTER PROGRAMMING FUNDAMENTALS

RASPBERRY PI PROJECT IDEAS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which command replaces words in a file?
A
sed
B
uniq
C
wc
D
grep
Explanation: 

Detailed explanation-1: -Use Stream EDitor (sed) as follows: sed-i ‘s/old-text/new-text/g’ input.txt. The s is the substitute command of sed for find and replace . It tells sed to find all occurrences of ‘old-text’ and replace with ‘new-text’ in a file named input.txt.

Detailed explanation-2: -The Linux sed command is most commonly used for substituting text. It searches for the specified pattern in a file and replaces it with the wanted string. To replace text using sed, use the substitute command s and delimiters (in most cases, slashes-/ ) for separating text fields.

Detailed explanation-3: -For replacing a variable value using sed, we first need to understand how sed works and how we can replace a simple string in any file using sed. In this syntax, you just need to provide the string you want to replace at the old string and then the new string in the inverted commas.

There is 1 question to complete.