I want to search a file with name file.txt in a directory and replace entire line in those files with a string aprun by another line vasprun = "mpirun -np 64 vasp" How can I do this with awk or sed or any other bash utility?
2 Answers
With GNU bash and GNU sed:
shopt -s globstar sed -i 's/.*aprun.*/vasprun = "mpirun -np 64 vasp"/' -- **/file.txt From man bash:
globstar: If set, the pattern ** used in a pathname expansion context will match all files and zero or more directories and subdirectories. If the pattern is followed by a /, only directories and subdirectories match.