sed command

LINUX-Frequently used commands

sed command Converting characters.
Syntax
sed   [Option]  [file-name]
The sed command is used to bulk replace a string of characters in a file.
If you have a file with a lot of characters, you can use this command to replace them all at once.
When you run the command, specify the file as an argument.
Frequently used options
-e   Specify the process
-f    Specify the file in which the process is written.
Example: Replace a string in a file.
If you look at the contents of temp.txt
$  cat temp.txt
abcdefg  12345 wwwzzz   usj
$  sed -e "s/12345/ABCSEFG/"  temp.txt  ←Replace "12345" with "ABCSEFG".

abcdefg  ABCSEFG wwwzzz   usj.
Example: Replace a string with a specified file.
$  cat -e  temp1.txt   ← Run it with the option "-e".
If you look at the contents of temp.txt
$  cat temp.txt
abcdefg  12345 wwwzzz   usj.
$ cat sedfile  ←Displays the contents of the file containing the replacement process.
s/12345/ABCSEFG/
$  sed -f sedfile  temp.txt    ←Run the sed command with the file describing the process..
Copied title and URL