Bash: Difference between revisions
Jump to navigation
Jump to search
Line 46: | Line 46: | ||
echo "${HADOOP_SCHEDULER} » Min » ${MINMAX_CAPACITY[0]} » Max » ${MINMAX_CAPACITY[1]}";\ | echo "${HADOOP_SCHEDULER} » Min » ${MINMAX_CAPACITY[0]} » Max » ${MINMAX_CAPACITY[1]}";\ | ||
done | done | ||
</source> | |||
==Lines Match Between== | |||
<source lang='bash' highlight='3,6,8,10,14,17,20-23' line> | |||
bash <<'EOF' > academia_keycloak_staging.sql | |||
# suppress stdout | |||
echo '/* $STDOUT$' | |||
echo "${HOSTNAME}${HOME}" | |||
ssh -qt gtw.vpc.chorke.org <<'EOF_00' | |||
echo "${HOSTNAME}${HOME}" | |||
ssh -qt rds.vpc.chorke.org <<'EOF_01' | |||
echo "${HOSTNAME}${HOME}" | |||
echo '$STDOUT$ */' | |||
pg_dump -U postgres academia_keycloak_staging | |||
# suppress stdout | |||
echo '/* $STDOUT$' | |||
EOF_01 | |||
EOF_00 | |||
echo '$STDOUT$ */' | |||
EOF | |||
sed '/^\/\* \$STDOUT\$$/,/^\$STDOUT\$ \*\/$/{/^\/\* \$STDOUT\$$/!{/^\$STDOUT\$ \*\/$/!d}}' -i academia_keycloak_staging.sql | |||
sed -z 's|\n/\* $STDOUT$\n$STDOUT$ \*/||g' -i academia_keycloak_staging.sql | |||
sed -z 's|/\* $STDOUT$\n$STDOUT$ \*/\n||g' -i academia_keycloak_staging.sql | |||
gzip academia_keycloak_staging.sql | |||
</source> | </source> | ||
Revision as of 10:39, 5 January 2023
sudo systemctl stop firewalld
sudo systemctl stop ipchains
sudo systemctl stop iptables
sudo systemctl restart jira
sudo systemctl restart atlbitbucket
# clear all
history -c
history -w
# delete line
history -d 2013
history -w
for i in {1..50};do \
history -d 2013;done;\
history -w
count=`wc -l ~/.bash_history|awk '{print $1+1}'`;start_line=$(($count-10));\
for ((line=$count;line>=$start_line;--line));do history -d $line;done;\
history -w
command -v __git_ps1 >/dev/null 2>&1 || { echo >&2 "__git_ps1 not installed";}
hash __git_ps1 >/dev/null 2>&1 || { echo >&2 "__git_ps1 not installed";}
type __git_ps1 >/dev/null 2>&1 || { echo >&2 "__git_ps1 not installed";}
# check by using if else conditional block
if hash __git_ps1 2>/dev/null;then echo '__git_ps1';\
else echo 'no __git_ps1';fi
Bash Arrays
declare -ax HADOOP_SCHEDULERS=(dev prod);\
declare -Ax MINMAX_CAPACITIES=([dev]='50 50' [prod]='50 70');\
for HADOOP_SCHEDULER in ${HADOOP_SCHEDULERS[@]};do \
IFS=' ' read -r -a MINMAX_CAPACITY <<< "${MINMAX_CAPACITIES[${HADOOP_SCHEDULER}]}";\
echo "${HADOOP_SCHEDULER} » Min » ${MINMAX_CAPACITY[0]} » Max » ${MINMAX_CAPACITY[1]}";\
done
Lines Match Between
bash <<'EOF' > academia_keycloak_staging.sql
# suppress stdout
echo '/* $STDOUT$'
echo "${HOSTNAME}${HOME}"
ssh -qt gtw.vpc.chorke.org <<'EOF_00'
echo "${HOSTNAME}${HOME}"
ssh -qt rds.vpc.chorke.org <<'EOF_01'
echo "${HOSTNAME}${HOME}"
echo '$STDOUT$ */'
pg_dump -U postgres academia_keycloak_staging
# suppress stdout
echo '/* $STDOUT$'
EOF_01
EOF_00
echo '$STDOUT$ */'
EOF
sed '/^\/\* \$STDOUT\$$/,/^\$STDOUT\$ \*\/$/{/^\/\* \$STDOUT\$$/!{/^\$STDOUT\$ \*\/$/!d}}' -i academia_keycloak_staging.sql
sed -z 's|\n/\* $STDOUT$\n$STDOUT$ \*/||g' -i academia_keycloak_staging.sql
sed -z 's|/\* $STDOUT$\n$STDOUT$ \*/\n||g' -i academia_keycloak_staging.sql
gzip academia_keycloak_staging.sql
Knowledge
sudo apt install neofetch neofetch --cpu-brand off neofetch
# add the new key(s) to known_hosts ssh-keyscan -H git.academia.chorke.org >> ~/.ssh/known_hosts # remove the old key(s) from known_hosts ssh-keygen -R git.academia.chorke.org
cat /etc/os-release