To replace all occurences of string1 in a file with string2 : $ sed -ri "s|string1|string2|" some_file.txt