How can I replace line #6 in a text file in a bash script?

Solution 1:

Try sed "6s/old/new/g" file.txt