msguides/office 2016.txt
File Existence Check:
ruby if File.exist?('msguides/office 2016.txt')
Checks if the file "msguides/office 2016.txt" exists.File Reading:
ruby file_content = File.read('msguides/office 2016.txt')
Reads the content of the file "msguides/office 2016.txt" and stores it in the variablefile_content
.String Replacement:
ruby modified_content = file_content.gsub('old_text', 'new_text')
Replaces occurrences of 'old_text' with 'new_text' in thefile_content
and stores the modified content in the variablemodified_content
.File Writing:
ruby File.write('msguides/office 2016.txt', modified_content)
Writes the modified content back to the file "msguides/office 2016.txt", effectively updating its content.
Note: Replace 'old_text' and 'new_text' with the actual values you want to replace in the file.