shell command

cat /tmp/Invoice_tmp.txt | grep -v "affected" | sort | awk '{print}' > /tmp/result.txt 去掉affected那行,排序,  将内容输出到result.txt

服务器之间复制文件:将本地的/var/tmp/cg35690/Invoice.txt 复制到另一个服务器的hdcicgcmola01d  的 这个path 下  /var/tmp/cg35690/

scp local file path id@remoteservername:remotepath

DEMO: scp /var/tmp/cg35690/Invoice.txt cg35690@hdcicgcmola01d:/var/tmp/cg35690/

InvoiceReport_Recon.csh

#!/bin/csh -f
set TMPDIR = "/tmp"
set PVD1 = "Invoice.txt"
set num=`awk '/^$/{print NR}' $TMPDIR/$PVD1`#####以换行符为条件进行获取行号
set tmp=0
set LoopCnt = 0

echo "--------------------------------------"
echo "Start to prepare test files: $TMPDIR/$PVD1"
if (-e $TMPDIR/$PVD1) then
 echo "$TMPDIR/$PVD1 exist"
 echo "num is $num"
 foreach i ( $num )
   @ LoopCnt += 1
    echo "Start loop"
    if ($tmp == 0) then
      #sed -n '1,7p' $TMPDIR/$PVD1 > $TMPDIR/Invoice_tmp.txt   ######打印1-7 行到文件
      awk "NR>1 && NR<$i" $TMPDIR/$PVD1 > $TMPDIR/Invoice_tmp.txt ######打印1-i 行到文件
    else
      #sed -n "${tmp},${i}p" $TMPDIR/$PVD1 > $TMPDIR/Invoice_tmp.txt ######打印tmp-i 行到文件
      awk "NR>$tmp && NR<${i}" $TMPDIR/$PVD1 > $TMPDIR/Invoice_tmp.txt   ######打印tmp-i 行
    endif
    set tmp=${i}
   # cat /tmp/Invoice_tmp.txt | sed '/rows affected/d' | sort | awk '{print}' > $TMPDIR/Invoice${LoopCnt}.txt
    cp $TMPDIR/Invoice_tmp.txt  $TMPDIR/Invoice${LoopCnt}.txt
    echo "i is ${i}, temp is $tmp,LoopCnt is ${LoopCnt}"
 end
else
 echo "$TMPDIR/$PVD1 not exist"

endif

SFTP 链接其他server进行文件传输 : sftp id@outservername

sftp newaska@hdcicgcmola01d << EOF cd /home/sb/newaska/share/bin put /home/sb/jesseq/uat/daily_tasks/filerecon/InvoiceReport_Recon.csh EOF

SSH 链接其他server 执行脚本

ssh -t -t newaska@hdcicgcmola01d << EOF
chmod +x /home/sb/newaska/share/bin/InvoiceReport_Recon.csh
/home/sb/newaska/share/bin/InvoiceReport_Recon.csh
EOF
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值