shell - How can I replace a specific line of a file in bash script? -


i have file inside 1 directory, want replace 1 specific line line.

in case line - "password requisite pam_pwquality.so" , want make as

"#password requisite pam_pwquality.so".

i tried this:

 cat test1 | while read line            if grep -q "$str" test1;             echo "found"             sed -i -e "s/${str}/${str1}/g" test1         fi 

but showing multiple found statements having 1 copy of line.

$ x='password requisite pam_pwquality.so' $ sed -i "s/\($x\)/#\1/" file 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -