echo

linux启动java程序

丶灬走出姿态 提交于 2020-01-10 11:40:19
Linux下shell通用脚本启动jar(微服务) vim app_jar.sh #!/bin/bash #source /etc/profile # Auth:Liucx # Please change these parameters according to your real env. # set Java Home: Remember that dolphin only supports JDK8! JAVA_HOME=/usr/java/jdk1.8.0_162 # application directory cd `dirname $0` APP_HOME=`pwd` APP_NAME="`cd ${APP_HOME} && find -name '*.jar' `" JAR_HOME=`pwd |awk -F"/" '{print $NF}'` # Java JVM lunch parameters if [ x"$JAVA_MEM_OPTS" == x ];then JAVA_MEM_OPTS="-server -Xms512m -Xmx512m -Xmn128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX

PHP+MYSQL实现分页

五迷三道 提交于 2020-01-10 08:50:13
   一、分页程序的原理    分页程序有两个非常重要的参数:每页显示几条记录($pagesize)和当前是第几页($page)。有了这两个参数就可以很方便的写出分页程序,我 们以MySql数据库作为数据源,在mysql里如果要想取出表内某段特定内容可以使用的 T-SQL语句:select * from table limit offset,rows来实现。这里的offset是记录偏移量,它的计算方法是offset=$pagesize*($page-1),rows是要显 示的记录条数,这里就是$page。也就是说select * from table limit 10,10这条语句的意思是取出表里从第11条记录开始的20条记录。    二、主要代码解析 $pagesize=10; //设置每一页显示的记录数 $conn=mysql_connect("localhost","root",""); //连接数据库 $rs=mysql_query("select count(*) from tb_product",$conn); //取得记录总数$rs $myrow = mysql_fetch_array($rs); $numrows=$myrow[0]; //计算总页数 $pages=intval($numrows/$pagesize); //判断页数设置 // body brush

PowerShell “echo on”

隐身守侯 提交于 2020-01-10 08:17:08
问题 This is a duplicate of https://serverfault.com/questions/102098/powershell-script-showing-commands-run. I thought it would be more appropriate to ask this question here. I am playing around with PowerShell scripts and they're working great. However, I am wondering if there is any way to also show all the commands that were run, just as if you were manually typing them in yourself. This would be similar to "echo on" in batch files. I looked at the PowerShell command-line arguments, the cmdlets

Writing a function in php

独自空忆成欢 提交于 2020-01-10 06:09:38
问题 I am trying to work out how to write php functions, so that I don't have to keep writing a block of code over and over again, I am having a play around and tried writing this, but it doesnt work for some reason, can anyone tell me where I am going wrong ?. <?php $greeting 'Hello'; function frank () { $name = 'frank'; $2nd = 'robson'; echo $greeting; echo $name; echo $2nd; } echo frank() ?> 回答1: Instead of echoing inside your function you should consider returning a string with it. Also prefer

条件测试操作与流程控制语句

喜夏-厌秋 提交于 2020-01-10 05:22:05
在编写Shell脚本时候,经常需要判断两个字符串是否相等,检查文件状态或者是数字的测试等。Shell提供了对字符串、文件、数值等内容的条件测试以及逻辑流程控制。 条件测试操作 程序中的流程控制是由比较和测试语句来处理的,bash具备多种与UNIX系统级特性相兼容的执行测试方法。 常用测试操作 test 命令,测试特定的表达式是否成立,当条件成立时,命令执行后的返回值为0,否则为其他数值。 格式1 test 条件表达式 格式2 [ 条件表达式 ] //常用格式,使用方括号时,要注意在条件两边加上空格。 常见测试类型 测试文件状态 字符串的比较 整数值的比较 逻辑测试 测试文件 格式 [ 操作符 文件或目录 ] 操作符: -d:测试是否为目录,是则为真(Directory) -e:测试目录或文件是否存在,存在则为真(Exist) -f:测试是否为文件,是则为真( file ) -r:测试当前用户是否有权限读取,是则为真( read ) - w :测试当前用户是否有权限写入,是这为真( write ) -x:测试当前用户是否可执行该文件,可执行则为真(Excute) -L:测试是否为符号链接文件,是则为真(Link) -nt:file1 -nt file2 如果 file1 比 file2 新(修改时间),则为真 -ot:file1 -ot file2 如果 file1 比 file2

shell编程2

大城市里の小女人 提交于 2020-01-10 05:21:18
-------条件测试 test命令用于测试字符串,文件状态和数字。 1、测试文件状态 test命令一般有2种格式:test condition或[ condition ]使用方括号时注意在条件两边加上空格。 常用的测试文件的条件表达式有: -d:目录;-s:文件长度大于0、非空;-f:正规文件;-w:可写;-L:符号连接;-u:文件有suid位设置;-r:可读;-x可执行。 如:测试first文件是否可写: test -w first echo $? 返回0说明可写,否则不可写;或着: [ -w first ] echo $? 可以实现同样的功能。 2、字符串测试 字符串测试有5种格式: test 'string' test string_operator 'string' test 'string1" string_operator "string2' [ string_operatoer 'string' ] [ 'string1' string_operator 'string2' ] 其中string_operator可以是以下符号: =: 两个字符串相等; !=: 两个字符串不等 -z: 空串 -n: 非空串 如:a="dfsd" b="sdgfg"测试a和b是否相等为: [ '$a' = '$b'] echo $? 返回0说明相等,否则不相等。 3、测试数值

Echo batch file arrays using a variable for the index?

天大地大妈咪最大 提交于 2020-01-10 05:15:06
问题 If I have a batch file and I am setting arrays with an index that is a variable @echo off SET x=1 SET myVar[%x%]=happy How do I echo that to get "happy" ? I've tried ECHO %myVar[%x%]% ECHO %%myVar[%x%]%% ECHO myVar[%x%] But none of them work. It works fine if I use the actual number for the index ECHO %myVar[1]% But not if the index number is also a variable 回答1: SET x=1 SET myVar[%x%]=happy call echo %%myvar[%x%]%% set myvar[%x%] for /f "tokens=2* delims==" %%v in ('set myvar[%x%]') do @echo

批处理删除文件或列出文件用

时光总嘲笑我的痴心妄想 提交于 2020-01-10 03:59:08
自动删除几天前的文件 Windows 2003 2008测试通过 通过forfiles命令找到几天前的数据。 forfiles的几个参数: /P 可是搜索的路径。在我们这里就是要在哪个目录寻找要删除的文件 /M 根据搜索掩码搜索文件。默认为*,我们要删除某时间以前的文件。我们只关心时间。 /D 文件修改时间在某个时间之前或者之后。-200 表示200天之前的文件。 /C 表示为每个文件执行的命令,这里是要删除该文件所以为"cmd /c del /F /s /q @file"。其中变量@file表示该文件名。 综上所述,得出下列脚本: @echo off echo Del file ::::::::: echo forfiles /P D:\test\DATA /M * /S /D -200 /C "cmd /c del /F /s /q @file" echo forfiles /P D:\test\DATA /D -200 /C "cmd /c del @file" echo done echo . & pase 在linux下可以用find 命令来查找: find ./ -ctime 1 -name “*mail” -exec rm {} \; 删除一天前修改的文件。 rem 删除前一天的历史数据 forfiles /m *.fc /s /D -1 /c "cmd /c del

linux shell 字符串比较相等、不相等

杀马特。学长 韩版系。学妹 提交于 2020-01-10 03:55:41
#!/bin/sh #测试各种字符串比较操作。 #shell中对变量的值添加单引号,爽引号和不添加的区别:对类型来说是无关的,即不是添加了引号就变成了字符串类型, #单引号不对相关量进行替换,如不对$符号解释成变量引用,从而用对应变量的值替代,双引号则会进行替代 A="$1" B="$2" echo "输入的原始值:A=$A,B=$B" #判断字符串是否相等 if [ "$A" = "$B" ];then echo "[ = ]" fi #判断字符串是否相等,与上面的=等价 if [ "$A" == "$B" ];then echo "[ == ]" fi #注意:==的功能在[[]]和[]中的行为是不同的,如下 #如果$a以”a”开头(模式匹配)那么将为true if [[ "$A" == a* ]];then echo "[[ ==a* ]]" fi #如果$a等于a*(字符匹配),那么结果为true if [[ "$A" == "a*" ]];then echo "==/"a*/"" fi #File globbing(通配) 和word splitting将会发生, 此时的a*会自动匹配到对应的当前以a开头的文件 #如在当前的目录中有个文件:add_crontab.sh,则下面会输出ok #if [ "add_crontab.sh" == a* ];then #echo

Linux Shell一些常用记录(一)

白昼怎懂夜的黑 提交于 2020-01-09 21:06:23
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 终端打印 echo ''单引号内$变量无效,""双引号内$变量有效,``反撇号为可执行命令,并且可以把命令结果给变量赋值 #!/bin/bash no1=2; no2=3; let result=no1+no2 echo $result echo -e 解析转义字符,如\n换行 文件重定向 重定向将输入文本 通过截取模式 保存到文件: echo "this is a text line one" > test .txt 写入到文件之前,文件内容首先会被清空。 重定向将输入文本 通过追加模式 保存到文件: echo "this is a text line one" >> test.txt 写入到文件之后,会追加到文件结尾。 标准错误输出的重定向方法: 方法一: [root@localhost text]# cat linuxde.net 2> out.txt //没有任何错误提示,正常运行。 方法二: [root@localhost text]# cat linuxde.net &> out.txt [root@localhost text]# cat linuxde.net 2> /dev/null /dev/null是一个特殊的设备文件,这个文件接受到任何数据都会被丢系,通常被称为位桶、黑洞。 if条件语句