DEV Community

Cover image for CONCLUSION ON BASH SCRIPTING
Kenneth Mahon
Kenneth Mahon

Posted on

CONCLUSION ON BASH SCRIPTING

Good day Everyone; i'm so sorry i haven't been consistent updating us on my journey so far; work have really been demanding this days and taking alot of time but notwithstanding, my journey is not fading away.
i won't be consistent in posting due to work but the 120 days of Learning devOps still intact; surely going to achieve it.

to round up bash scripting before moving to python, i will be rounding up by sharing some scripting; interpret it and run it to see the result. i will also sharing a resources that covers all we have discussed about in my previous post on bash scripting
LET GOOOOOO!!!!!!

script 1

#!/bin/bash


read -p "Enter file name: " file_name
read -p "Enter search term: " search_term

if [ ! -f $file_name ]; then
    echo "File not found"
    exit 1
fi

while read line
do
    if [[ $line == *"$search_term"* ]]; then

        new_line=${line//$search_term/new_value}
        echo $new_line
    else
        echo $line
    fi
done < $file_name
Enter fullscreen mode Exit fullscreen mode

script 2

for file in *.txt; do
  mv "$file" "${file%.txt}.doc"
done
Enter fullscreen mode Exit fullscreen mode

Script 3

while ps -p 1234 >/dev/null; do
    sleep 1
done
Enter fullscreen mode Exit fullscreen mode

That is all. play with it and share your interpretation and output in the comment section. Day 15 loading.......

RESOURCES:
Bash scripting for beginners

Top comments (0)