Some bash scripts

setInterval in bash

1
while true; do ls -l; sleep 2; done

count files fastly

1
find . -type f | wc -l

find files that large than 1 GiB

1
find . -type f -size +1G

test if file exist

1
2
3
4
5
6
myFile="/home/lxw/abc"
if [ ! -f "$myFile" ]; then
touch "$myFile"
else
echo "skip"
fi

kill process

find all dart process and kill them all

1
2
3
4
# find
ps -aux | grep dart
# find && kill
pgrep -f dart | xargs kill

Wifi

1
2
3
4
5
# connect to wifi
sudo nmcli d wifi connect iPhone password 11345678
# show saved connections
ls -sail /etc/NetworkManager/system-connections/