Jump to content

Bash Script - Echo at Break

Go to solution Solved by vorticalbox,

put it before the break.

Hi,

#!/bin/bash
sourceFile="file.log"
targetFile="2file.log"
ping="1.1.2.3"
while IFS='' read -r line || [[ -n "$line" ]]; do
        echo "allow-hotplug wlan0" > "$targetFile"
        echo "iface wlan0 inet static" >> "$targetFile"
        echo "address 192.168.0.2" >> "$targetFile"
        echo "netmask 255.255.255.252" >> "$targetFile"
        echo "wireless-channel 6" >> "$targetFile"
        echo "wireless-essid grewep" >> "$targetFile"
        echo "wireless-mode ad-hoc" >> "$targetFile"
        echo "$line" >> "$targetFile"
        ping -q -c 5 "$ping"
        ping2=$?
        if [ "$ping2" -ne 0 ]; then
                break
        fi
        sed -n -e '8p' "$targetFile"
done < "$sourceFile"

Is there a way to echo text, at the point of break in the if statement?

Thank you

Link to comment
https://linustechtips.com/topic/742217-bash-script-echo-at-break/
Share on other sites

Link to post
Share on other sites

put it before the break.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×