sed The Stream EDitor sed file.txt Same as cat file.txt sed -e '10q' file.txt Output first 10 lines sed -n -e '10,20p' file.txt Output lines 10 to 20 sed -e 's/foo/bar/g' file.txt Replace all 'foo' with 'bar' More info: man sed