awk refactor of my scripts
awk is OP man - so easy to use and does a bunch of stuff all at once without having to rely on multiple pipes. It comes with essentially every distribution so you'll always have access to it.
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
pgrep ".*" -l | dmenu -p "Choose process: " | sed "s/\\([0-9]*\\).*/\1/g" | xargs kill -9 $1
|
pgrep ".*" -l | dmenu -p "Choose process: " | awk '{ print $1 }' | xargs kill -9 $1
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
devices=$(bluetoothctl devices Connected | grep -oE '([0-9A-Fa-f:]{17})')
|
devices=$(bluetoothctl devices Connected | awk '{print $2}')
|
||||||
|
|
||||||
if [ -z "$devices" ]
|
if [ -z "$devices" ]
|
||||||
then
|
then
|
||||||
echo ""
|
echo ''
|
||||||
else
|
else
|
||||||
acc=""
|
sep=''
|
||||||
|
printf ' '
|
||||||
for mac in $devices
|
for mac in $devices
|
||||||
do
|
do
|
||||||
name=$(bluetoothctl info $mac | grep "Alias" | sed 's/.*Alias: //')
|
name=$(bluetoothctl info $mac | awk -F ': ' '/Alias/ { print $2 }')
|
||||||
battery=$(bluetoothctl info $mac | grep "Battery Percentage" | sed 's/.*(//;s/)//')
|
battery=$(bluetoothctl info $mac | awk -F '[()]' '/Battery Percentage/ { print $2 }')
|
||||||
acc="$acc $name"
|
|
||||||
|
printf "$sep<$name"
|
||||||
if [ "$battery" ]
|
if [ "$battery" ]
|
||||||
then
|
then
|
||||||
acc="$acc ($battery%)"
|
printf " $battery%%"
|
||||||
fi
|
fi
|
||||||
|
printf ">"
|
||||||
|
sep=" "
|
||||||
done
|
done
|
||||||
|
printf "\n"
|
||||||
echo "$acc"
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
internet=$(nmcli g | sed -n 2p | awk '{print $1}')
|
internet=$(nmcli g | awk 'NR == 2 {print $1}')
|
||||||
if [[ $internet == "connected" ]]
|
if [[ $internet == "connected" ]]
|
||||||
then
|
then
|
||||||
con=$(nmcli | grep "connected to" | sed "s/.*: connected to \(.*\)/\1/g")
|
con=$(nmcli | awk -F "to " '/connected to/ { print $2 }')
|
||||||
echo "" $con
|
echo "" $con
|
||||||
else
|
else
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
echo "㊋ $(sensors | grep "Tctl" | sed 's/Tctl:.*+\(.*\)C.*/\1/')C"
|
data=$(sensors | awk -F'+' '/Tctl/ { gsub(/[ \t]+$/, "", $2); print $2 }')
|
||||||
|
echo "㊋ $data"
|
||||||
|
|||||||
Reference in New Issue
Block a user