Tags » Shell Script

tech talk #3: one-line solutions!

don’t know about you, but i simply love one-line solutions! yesterday i wrote a relatively long text about a topic that haunts us every now and then – even though the motivation of those who think a military coup would solve our problems is somehow understandable, i should say that… 168 more words

Linux

bandwidth control script for some ips

#!/bin/bash

BANDWIDTH_KBIT=7000
BANDWIDTH_INTERFACE=eth0
FINAL_IPs_WITH_BANDWIDTH_CONTROL=(7 8 50 111)
LAN_IP=$( ip addr show $BANDWIDTH_INTERFACE | grep -Eo '({1,3}\.){3}' | sed -n 1p )

# clear all tc rules
tc qdisc del dev $BANDWIDTH_INTERFACE root

# create tc rules 
tc qdisc add dev $BANDWIDTH_INTERFACE root handle 1: htb

for i in ${FINAL_IPs_WITH_BANDWIDTH_CONTROL[*]}; do
  tc class add dev $BANDWIDTH_INTERFACE classid 1:${i} htb rate ${BANDWIDTH_KBIT}kbit
  tc filter add dev $BANDWIDTH_INTERFACE parent 1: protocol ip prio 1 u32 match ip dst $LAN_IP${i} flowid 1:${i}
done
… 31 more words
Shell Script

replace char/word in shell script

substitute whitespace by commas to generate csv output

echo a b c | tr -s ' ' ','
Shell Script

search for string in big source code linux

search for tty string in all .sh files in /etc dir

for i in $( find /etc -name *.sh );do OUT=$( grep -i 'tty' $i ); test "$OUT" && echo -e "\n$i\n$OUT"; done
… 78 more words
Shell Script

Gpg - can't connect to `/home/${USER)/.gnupg/S.gpg-agent': No such file or directory

Recently, I got below error while I was trying to create new gpg key:

can’t connect to `/home/aykut/.gnupg/S.gpg-agent’: No such file or directory
gpg-agent: command get_passphrase failed: Operation cancelled…

224 more words
Linux