echo

Sqlplus printing the result twice and with an empty line

泄露秘密 提交于 2019-12-31 04:02:26
问题 I write shell script and want to use sqlplus, when I write: #!/bin/bash result=$(sqlplus -s user/pass@DB << EOF set trimspool on; set linesize 32000; SET SPACE 0; SELECT MAX(DNNCMNT_ANSWER_TIME) FROM TKIMEI.DNNCMNT_IMEI_APPRV; / exit; EOF) echo "$result" the result is in txt file (I'm executing it as ksh sql.sh > result.txt ): MAX(DNNCM --------- 10-MAR-14 MAX(DNNCM --------- 10-MAR-14 it is automatically putting an empty line at the beginning of file and writing the result twice. How can I

如何用php实现分页效果

牧云@^-^@ 提交于 2019-12-31 02:32:08
分页效果在网页中是常见的,可是怎样才能实现分页呢,今天做了两种方法来实现一下分页的效果 首先,我们需要准备在数据库里面准备一个表,并且插入数据,这些都是必需的前提工作了,不多说,如图所示(库名为jereh,表名为n_content): 步骤分析: 我们需要分页的话,需要用到 " select * from tableName limit num1,num2”;这是一个限定查询的语句,后面跟两个参数,num1为从第几个开始查找,num2为查找的信息的个数,如我想查找2,3,4这三条数据,如下图所示 好了,我们开始说步骤: 1.建立一个函数,用来实现限制查询的功能 首先我们来想一下,实现这个功能我们首先要知道当前的页数和要限制的一个页面显示几条信息,这个可以用形参传过来,那么, 我们设置pageNum为页数,pageSize为一个页面显示几条数据,在 "select * from tableName limit num1,num2”这个查询语句中, num1就是(pageNum-1)*pageSize,num2就是pageSize,明白了这个关系之后,那么就好办了,代码在下面 //分页的函数 function news($pageNum = 1, $pageSize = 3) { $array = array(); $coon = mysqli_connect("localhost",

bash output command not found

可紊 提交于 2019-12-31 01:45:24
问题 Im facing following problem I have created mentioned condition, but when I choose y for yes everything is ok, but when I choose n for not I get annoying error output: output : Do you agree yes (y) or not (n) n ./myscript: [n: command not found myscript is the name of my script Code here: echo "Do you agree yes (y) or not (n)" read answer if ( [ "$answer" = 'y' ] || ["$answer" = 'Y' ]); then echo -e “ output for y” done else echo -e " output for n " exit 1; Any idea how can I get rid of the

centos 安装nginx

可紊 提交于 2019-12-31 01:19:39
1、准备工作 选首先安装这几个软件:GCC,PCRE(Perl Compatible Regular Expression),zlib,OpenSSL。 Nginx是C写的,需要用GCC编译;Nginx的Rewrite和HTTP模块会用到PCRE;Nginx中的Gzip用到zlib; 用命令“# gcc”,查看gcc是否安装;如果出现“gcc: no input files”信息,说明已经安装好了。 否则,就需要用命令“# yum install gcc”,进行安装了!一路可能需要多次输入y,进行确认。 安装好后,可以再用命令“#gcc”测试,或者用命令“# gcc -v”查看其版本号。 同样方法,用如下命令安装PCRE,zlib,OpenSSL(其中devel,是develop开发包的意思): # yum install -y pcre pcre-devel # yum install -y zlib zlib-devel # yum install -y openssl openssl-devel 2、下载并安装 创建目录(nginx)并进去;然后,从官方地址(http://nginx.org/)下载,解压,配置,编译,安装: # mkdir nginx && cd nginx # wget http://nginx.org/download/nginx-1.7.3.tar

use both html and php in echo and href line

怎甘沉沦 提交于 2019-12-30 14:54:38
问题 I have the variable: $myvar = 'myarchive.pdf'; How can I embedd it to this: echo('<tr> <td> <a href="nextpage.php?file=trial.pdf"> download now </a> </td> </tr>'); I wonder if there is a way to do it like this: echo('<tr> <td> <a href="nextpage.php?file=".'$myvar'.> download now </a> </td> </tr>'); 回答1: You are not appending the variable to the string properly. Also you have to enclose nextpage.php?file=variable within quotes. But you are closing it before the variable name. <a href="nextpage

use both html and php in echo and href line

自作多情 提交于 2019-12-30 14:54:10
问题 I have the variable: $myvar = 'myarchive.pdf'; How can I embedd it to this: echo('<tr> <td> <a href="nextpage.php?file=trial.pdf"> download now </a> </td> </tr>'); I wonder if there is a way to do it like this: echo('<tr> <td> <a href="nextpage.php?file=".'$myvar'.> download now </a> </td> </tr>'); 回答1: You are not appending the variable to the string properly. Also you have to enclose nextpage.php?file=variable within quotes. But you are closing it before the variable name. <a href="nextpage

Linux shell 提取文件名和目录名

馋奶兔 提交于 2019-12-30 10:06:51
${}用于字符串的读取,提取和替换功能,可以使用${} 提取字符串 1、提取文件名 [root@localhost log]# var=/dir1/dir2/file.txt [root@localhost log]# echo ${var##*/} file.txt 2、提取后缀 [root@localhost log]# echo ${var##*.} txt 3、提取不带后缀的文件名,分两步 [root@localhost log]# tmp=${var##*/} [root@localhost log]# echo $tmp file.txt [root@localhost log]# echo ${tmp%.*} file 4、提取目录 [root@localhost log]# echo ${var%/*} /dir1/dir2 使用文件目录的专有命令basename和dirname 1、提取文件名,注意:basename是一个命令,使用$(), 而不是${} [root@localhost log]# echo $(basename $var) file.txt 2、提取不带后缀的文件名 [root@localhost log]# echo $(basename $var .txt) file 3、提取目录 [root@localhost log]# dirname

echo from lines of a file

风流意气都作罢 提交于 2019-12-30 08:53:20
问题 i have a file "myfile.txt" that have the next content: hola mundo hello word and i want work with every line for i in `cat myfile.txt`; do echo $i; done i hope this give me hola mundo hello word firts one line, then the other, but get hola mundo hello word as I can demanding results until newline instead of each space? ty all 回答1: That's better cat myfile.txt | while read line; do echo "$line" done or even better (doesn't launch other processes such as a subshell and cat ): while read line;

Why is '…' concatenating two numbers in my code?

自作多情 提交于 2019-12-30 05:55:08
问题 I have the following code snippet where I don't really understand its output: echo 20...7; Why does this code output 200.7 ? From what I know ... is the splat operator, which it is called in ruby, that lets you have a function with a variable number of arguments, but I don't understand what it does here in the context with echo . Can anyone explain what exactly this code does? 回答1: No this is not the splat/unpacking operator, even thought it might seem like it is. This is just the result of

Preserve linebreak txt php

廉价感情. 提交于 2019-12-30 05:14:07
问题 How can I read a .txt file from my server, and preserve it's linebreaks? Note that the linebreaks aren't like this /n or something, they are more like this. You know, just a new line in plain text. I would like to echo the .txt file from my server, this is in PHP or something, while preserving the linebreaks. Thanks a heck in advance ! :) 回答1: For output? Just use nl2br $file = file_get_contents( 'file.txt' ); echo nl2br( $file ); Also works with fopen . 回答2: The line breaks are preserved