Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit a file with one command?

i have a question:

How can i edit a file (e.g. php.ini) without opening it with editor? I can only use one command via SSH/SOAP so i tried to remove the file and write it new but this is slow and doesn't work well.

for example i want to edit this post_max_size = 8M to post_max_size = 32M with one single command. Is that possible?

like image 242
CodeBrauer Avatar asked Sep 14 '25 08:09

CodeBrauer


1 Answers

Stream edit - also known as "sed" is your friend.

sed 's/post_max_size = 8M/post_max_size = 32M/' infile > outfile

sed -i 's/post_max_size = 8M/post_max_size = 32M/' inplace_file
like image 101
Udo Klein Avatar answered Sep 17 '25 02:09

Udo Klein