From c1ee1c0d7f074409a8f29b16b982b79cad6016d5 Mon Sep 17 00:00:00 2001 From: Nuno Aguiar Date: Sat, 30 Mar 2024 20:36:10 +0000 Subject: [PATCH] +oafp-examples --- oafp-examples.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 oafp-examples.yaml diff --git a/oafp-examples.yaml b/oafp-examples.yaml new file mode 100644 index 0000000..bcc8d2f --- /dev/null +++ b/oafp-examples.yaml @@ -0,0 +1,35 @@ +- c: Unix + s: Generic + d: "Creates a data.ndjson file where each record is formatted from json files in /some/data" + e: |- + find /some/data -name "*.json" -exec oafp {} output=json \; > data.ndjson +- c: Unix + s: Generic + d: Parse /proc/cpuinfo into an array + e: |- + cat /proc/cpuinfo | sed "s/^$/---/mg" | ./oafp in=yaml path="[?not_null(@)]" out=ctree +- c: Unix + s: Generic + d: Parse the result of the ls command + e: |- + ls -lad --time-style="+%Y-%m-%d %H:%M" * | oafp in=lines path="map(&split_re(@,'\\s+').{permissions:[0],id:[1],user:[2],group:[3],size:[4],date:[5],time:[6],file:[7]},[])" linesjoin=true out=ctable +- c: Unix + s: Generic + d: Parse the result of the route command + e: |- + route | sed "1d" | oafp in=lines linesjoin=true linesvisual=true linesvisualsepre="\s+" out=ctable +- c: Unix + s: Generic + d: Parse the 'ip tcp_metrics' command + e: |- + ip tcp_metrics | sed 's/^/target: /g' | sed 's/$/\n\n---\n/g' | sed 's/ \([a-z]*\) /\n\1: /g' | head -n -2 | oafp in=yaml path="[].{target:target,age:from_timeAbbr(replace(age,'[sec|\.]','','')),cwnd:cwnd,rtt:from_timeAbbr(rtt),rttvar:from_timeAbbr(rttvar),source:source}" sql="select * order by target" out=ctable +- c: Unix + s: Generic + d: Parse the ‘arp’ command output + e: |- + arp | oafp in=lines linesvisual=true linesjoin=true out=ctable +- c: Unix + s: Debian/Ubuntu + d: List all installed packages + e: |- + apt list --installed | sed "1d" | oafp in=lines linesjoin=true path="[].split(@,' ').{pack:split([0],'/')[0],version:[1],arch:[2]}" out=ctable