Bash Script - Printing line to file loop
Go to solution
Solved by Tomsen,
2 hours ago, spbr said:So the other commands that I want to execute after the each print will be:
- restart network
- ping network
- if successful save file
- if not, print next line and repeat same cyle
Just make a loop where you read the sourceFile line by line.
Something like:
while IFS='' read -r line || [[ -n "$line" ]]; do echo "$line" >> "$targetFile" # Restart network # Ping # Check ping return code # Evaluate based on returned code done < "$sourceFile"
With a bit of research you should be able to solve it yourself in a couple of attempts.
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 accountSign in
Already have an account? Sign in here.
Sign In Now