Quick Find and do something commands
You are here
How to replace a string on the 5th line of multiple text files?
sed -i '5s/.*/ Good Morning /' file{1..4}.txtOr
# manually specified
sed -i '5s/.*/Good morning/' file1.txt file2.txt file3.txt file4.txt
# wildcard: all files on the desktop
sed -i '5s/.*/Good morning/' ~/Desktop/*
# brace expansion: file1.txt, file2.txt, file3.txt, file4.txt
sed -i '5s/.*/Good morning/' file{1..4}.txtHow can I do a recursive find and replace from the command line?
# Recursively find and replace in files find . -name "*.txt" -print0 | xargs -0 sed -i '' -e 's/foo/bar/g'
Category: