Sunday, March 23, 2025

Linux Simple Shell Script to copy the content into file and replace text

 Below script is the simple bash script to create a dummy file and replace text in the script.



#!bin/bash
cd /tmp
mkdir Test_script
cd Test_script
touch -a -m -t $(date +"%Y%m%d%H%M.%S") dummyfile_$(date +"%Y%m%d%H%M%S%3N").txt
echo "ORACLE_HOME=/opt/sw/oracle/client/home" > dummfile.txt
sed -e 's:/opt/sw/oracle/client/home:/opt/sw/oracle/Oracle19c/client/home:g' dummyfile.txt > dummy2.txt
diff dummyfile.txt dummy2.txt
ls -lrt

No comments: