Jump to content

Hi,

!/bin/bash
sourceFile="file.log"
targetFile="/etc/network/interfaces"
numLines="$(wc -l < ${sourceFile})"
counter=1
lineNumber=1
if (( counter >= "$numLines" )) || [[ ! -f "${sourceFile}" ]]; then
        echo "invalid file" >82; exit 1
fi
while [ "$counter" -le "$numLines" ]; 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"
        awk '{print "wireless-key s:",$0}' "$sourceFile" >> "$targetFile"
        counter=$((counter + 1))
done

With the above code, how would I print a permutation, then delete it, then print the next permutation, automatically in the bash script?

 

Thank you

 

Link to comment
https://linustechtips.com/topic/741401-bash-script-delete-line/
Share on other sites

Link to post
Share on other sites

http://www.tldp.org/LDP/abs/html/loopcontrol.html

 

http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_05.html

 

Quote

The break and continue loop control commands [1] correspond exactly to their counterparts in other programming languages. The break command terminates the loop (breaks out of it), while continue causes a jump to the next iteration of the loop, skipping all the remaining commands in that particular loop cycle.

@spbr

Link to comment
https://linustechtips.com/topic/741401-bash-script-delete-line/#findComment-9398603
Share on other sites

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

×