From 09061e21ab985b621617104c49f72f4331b8c9a4 Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Sat, 4 Jan 2025 14:34:17 +0200 Subject: [PATCH] Documentation minor update Signed-off-by: Denys Fedoryshchenko --- PPPOE_misc_tricks.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/PPPOE_misc_tricks.md b/PPPOE_misc_tricks.md index 7131709..8bc4a2e 100644 --- a/PPPOE_misc_tricks.md +++ b/PPPOE_misc_tricks.md @@ -79,3 +79,25 @@ If you see accel-pppd process you can start it with: /usr/sbin/accel-pppd -c /etc/accel-ppp.conf -p /var/run/accel-ppp.pid -d ``` +## Shell tricks + +For example i want to filter all lines that begin with "fadi" in users list: +``` +accel-cmd show sessions username|grep "^ fadi" +``` +What does it mean and how it works? + +* accel-cmd show sessions username - will show all sessions, but username field will be shown only +* | - pipe, it will pass output of previous command to next command +* grep "^ fadi" - will filter only lines that begin with " fadi", symbol ^ means beginning of line, space is needed to filter accel-specific output (it has space before username) + +Now, for example i want to save this list and disconnect all users that begin with "fadi": +``` +accel-cmd show sessions username|grep "^ fadi"|awk '{print $1}'|xargs -I {} accel-cmd terminate username {} +``` + +What does it mean and how it works? + +* awk '{print $1}' - will print first field of each line, which is username, it will remove leading space +* xargs -I {} - will pass each line to next command, {} is placeholder for line(variable) +* accel-cmd terminate username {} - will disconnect user by username