3

Getting the error:

(standard_in) 1: syntax error

When running the below script:

#!/bin/bash
while read line
do time=$(echo $line|awk '{print $10}'|awk -F"=" '{print $2}')
if (( $(echo "$time > 100" | bc -l) ))
then echo $line
fi
done  < ping.txt

The ping.txt file contains lines like below:

2018-08-15 13:45:54: 64 bytes from server.my.local (192.168.1.117): icmp_seq=7163 ttl=62 time=327 ms

basically i am trying to find all lines where time > 100 ms

1
  • This works for me, can't reproduce. I suspect that your logic to extract the time field fails on some lines and you end up with something that's not a number in time, but for the example input line, it works. Commented Aug 22, 2018 at 14:01

1 Answer 1

3

Using awk:

awk -F'[ =]' '$(NF-1)>100' ping.txt

The time is the second-to-last field $(NF-1) when split using [ =].

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.