sh 壳牌秘密

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 壳牌秘密相关的知识,希望对你有一定的参考价值。

# Como enviar comandos por SSH

ssh otherhost /bin/bash << EOF
  ls some_folder; 
  ./someaction.sh 'some params'
  pwd
  ./some_other_action 'other params'
EOF

# ou

cat commands-to-execute-remotely.sh | ssh blah_server
0 */2 * * * /bin/bash /foo/bar/coleta.sh > /foo/bar/df_`date +'\%Y\%m\%d-\%H\%M'`.out 2> /foo/bar/df_`date +'\%Y\%m\%d-\%H\%M'`.err
du -gs DIR
# listar arquivos maiores que 1GB
find /db2/CTCPRD/ctcdata2 -type f | xargs du -g | awk '$1 >= 1'
#linux
awk -vRS=""

#AIX
grep -p
find /db2/CTCPRD/ctcdata1 -type f -printf "%s\t%p\n" | sort -n
du -g -a /db2/CTCPRD/ctcdata1 | awk 'BEGIN{FS="/"} NF<=5' | grep -v '0.00'
du -g /db2/CTCPRD/ctcdata2 | awk 'BEGIN{FS="/"} NF<=5'
#modo 1
cat tab.list | while read s t; do db2 connect to dbname; db2 -v "grant select on $s.$t to group db2sel"; db2 connect reset; done >db2sel_grants.out

#modo 2
for TABNAME in `awk ‘{print $1″.”$2}’ tab.list`; do db2 -v “grant select on table $TABNAME to group db2sel” ; done
# Organiza por tamanho dos arquivos, em DESC
ls -l | sort -nrk5
# n = numerical (considerar ponto, virgula, etc.)
# r = DESC
# k = qual coluna considerar
xargs 
-p : prompt
-n2 : agrupa argumentos 2 em 2
-I %  - variavel aparece em %

find -print0 | xargs -0
# portmir -t 
sed 's/^.*\"####\"//g' count.sql -- apaga todo até os messages ###
vi :%s/FROM/FROM1/               -- troca os primeiros FROM para FROM1
sed 's/SELECT.*FROM1/SELECT COUNT(\*) FROM/' -- troca os primeiros SELECT .... FROM1 para SELECT COUNT(*) FROM

awk '{gsub("\"####\"", $3".msg")} {print $0}' export_c3_diario_prod_2017-09-10.sql
#! /bin/bash

function get_df {
	if sshpass -p "$2" ssh -oStrictHostKeyChecking=no "$1"@"$3" 'hostname; df -k  | grep -i log_archive' 2> /dev/null ; then
		echo ""
	else
		echo "$1@$3 FAILED" >&2
		echo ""
	fi
}

read -p "Usuario: " myusername
read -s -p "Senha: " mypassword
echo "" >&2
echo "" >&2
echo "########################### Data coleta: " `date +'%d-%m-%Y %H:%M'`
echo ""

get_df "$myusername" "$mypassword"  XXX.XXX.XXX.XXX
get_df "$myusername" "$mypassword"  XXX.XXX.XXX.XXX

以上是关于sh 壳牌秘密的主要内容,如果未能解决你的问题,请参考以下文章

sh 壳牌栈数据结构封装

sh 壳牌邮件发送邮件

sh 壳牌前台后台,查看后台任务

sh 壳牌nohup

sh 壳牌完工(CentOS)

sh 壳牌下载整个网站