Message ID | 20220514002115.725976-2-mathew.j.martineau@linux.intel.com (mailing list archive) |
---|---|
State | Accepted |
Commit | c43ce39870b3cff3cefb1faf78c577153edc2dde |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | mptcp: Updates for net-next | expand |
On Fri, 13 May 2022 17:21:13 -0700 Mat Martineau wrote: > tc -n $ns2 -j -s action show action pedit index 100 | \ > + grep "packets" | \ > sed 's/.*"packets":\([0-9]\+\),.*/\1/' sed can do the grepping for you: sed -n 's/.*"packets":\([0-9]\+\),.*/\1/p' But really grepping JSON output seems weird. Why not use jq?
Hi Jakub, Thank you for the review and for having applied the patches! On 16/05/2022 22:13, Jakub Kicinski wrote: > On Fri, 13 May 2022 17:21:13 -0700 Mat Martineau wrote: >> tc -n $ns2 -j -s action show action pedit index 100 | \ >> + grep "packets" | \ >> sed 's/.*"packets":\([0-9]\+\),.*/\1/' > > sed can do the grepping for you: > > sed -n 's/.*"packets":\([0-9]\+\),.*/\1/p' Yes, thank you, that would have been shorter! > But really grepping JSON output seems weird. Why not use jq? We started to use 'jq' because we originally had to extract a few values from this command. At the end, we only needed to extract the number of packets and we didn't want all MPTCP tests to depend on 'jq' just for that. But because 'jq' is already needed for a few other selftests, next time we need to parse a JSON, we should use 'jq'! Cheers, Matt
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index d1de1e7702fb..7381d1f85209 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -2693,6 +2693,7 @@ fastclose_tests() pedit_action_pkts() { tc -n $ns2 -j -s action show action pedit index 100 | \ + grep "packets" | \ sed 's/.*"packets":\([0-9]\+\),.*/\1/' }