linux中输入输出的标准文件描述符

2015-7-6 杜世伟 Linux

#!/bin/bash
#linux中输入输出的标准文件描述符。
#linux将对象当做文件来处理,并用标准文件描述符来表示每个文件对象。每一个文件描述符都可以标识一个会话中打开的文件。
#每个过程中最多可以有9个文件描述符,其中前三个被bash shell指定用于特殊用途

#文件描述符 缩写 描述
#0 STDIN 标准输入
#1 STDOUT 标准输出
#2 STDERR 标准错误
#对于一个终端来讲,标准输入STDIN就是键盘、标准输出STDOUT和标准错误STDERR就是屏幕
#我们可以通过重定向符(<,>)来改变输入、输出和错误。

阅读全文>>

标签: linux shell

评论(0) 浏览(16440)

python 字符串截取

2015-7-1 杜世伟 Python

str = 'helloworld'
print(str[0:3]) #截取第一位到第三位的字符
print(str[:]) #截取字符串的全部字符
print(str[6:]) #截取第七个字符到结尾
print(str[:-3]) #截取从头开始到倒数第三个字符之前
print(str[2]) #截取第三个字符
print(str[-1]) #截取倒数第一个字符
print(str[::-1]) #创造一个与原字符串顺序相反的字符串
print(str[-3:-1]) #截取倒数第三位与倒数第一位之前的字符
print(str[-3:]) #截取倒数第三位到结尾
print(str[:-5:-3]) #逆序截取,具体啥意思没搞明白?

阅读全文>>

标签: python print

评论(0) 浏览(1795)

vim 大小写转换

2015-6-12 杜世伟 Vim

vim 大小写转换
平时在写程序时经常会遇到大小写转换的问题,vim中提供了很多非常方便的大小写转换命令,可以快速的进行字母、单词、任意行的大小写转换,可以和vim的光标移动指令组合使用。

We have commands like "tr", tools like "sed", strong one liners from perl to do the conversions of lowercase UPPERCASE Titlecase . "vi" too provides the same, some of its :ex commands are below.

平时在写程序的过程中会经常遇到大小写转换的问题.我们有命令tr和工具sed,vi有类似的功能:

范例:
 
:1,$ s/.*/\L&/ #整个文件全部转换为小写
:1,$ s/.*/\U&/ #整个文件全部转换为大写
:1,$ s/\<./\u&/g #整个文件中每个单词的首字母大写

阅读全文>>

标签: linux vim sed

评论(0) 浏览(15640)

linux wget 详解

2015-6-5 杜世伟 Linux

        wget是linux上的命令行的下载工具。这是一个GPL许可证下的自由软件。wget支持HTTP和FTP协议,支持代理服务器和断点续传功能,能够自动递归远程主机的目录,找到合乎条件的文件并将其下载到本地硬盘上;如果必要,wget将恰当地转换页面中的超级连接以在本地生成可浏览的镜像。由于没有交互式界面,wget可在后台运行,截获并忽略HANGUP信号,因此在用户推出登录以后,仍可继续运行。通常,wget用于成批量地下载Internet网站上的文件,或制作远程网站的镜像

阅读全文>>

标签: linux wget

评论(0) 浏览(6118)

shell 算术运算操作

2015-6-2 杜世伟 Linux

算术运算符指的是可以在程序中实现加、减、乘、除等数学运算的运算符。
Shell中常用的数学运算符如下所示。
 +:对两个变量做加法。
 -:对两个变量做减法。
 *:对两个变量做乘法。
 /:对两个变量做除法。
 **:对两个变量做幂运算。
 %:取模运算,第一个变量除以第二个变量求余数。
 +=:加等于,在自身基础上加第二个变量。
 -=:减等于,在第一个变量的基础上减去第二个变量。
 *=:乘等于,在第一个变量的基础上乘以第二个变量。
 /=:除等于,在第一个变量的基础上除以第二个变量。
 %=:取模赋值,第一个变量对第二个变量取模运算,再赋值给第一个变量。

阅读全文>>

标签: linux shell

评论(0) 浏览(9905)

Linux下安装 Memcached服务器端

2015-5-27 杜世伟 memcache

#!/bin/sh

#Author  :  shiwei.du
#Date    :  2016/04/08


#install libevent
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure --prefix=/usr/
make && make install
cd ..

阅读全文>>

标签: linux memcache memcached

评论(0) 浏览(13385)

./configure: error: SSL modules require the OpenSSL library

2015-5-19 杜世伟 Linux

make: *** No rule to make target `build', needed by `default'. Stop. ./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source

with nginx by using --with-openssl= option.


yum -y install openssl openssl-devel

标签: openssl openssl-devel

评论(0) 浏览(4528)

CentOS 7.0关闭默认防火墙启用iptables防火墙

2015-5-16 杜世伟 Linux

操作系统环境:CentOS Linux release 7.0.1406(Core) 64位
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。

1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

2、iptables防火墙(这里iptables已经安装,下面进行配置)
vi/etc/sysconfig/iptables #编辑防火墙配置文件
# sampleconfiguration for iptables service
# you can edit thismanually or use system-config-firewall
# please do not askus to add additional ports/services to this default configuration

阅读全文>>

标签: iptables centos firewall

评论(0) 浏览(14924)

phpize Cannot find autoconf

2015-5-10 杜世伟 Php

Centos下执行phpize提示“Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this scrIPt.”
原因:缺少autoconf
解决方法:
yum install autoconf

标签: PHP phpize autoconf

评论(0) 浏览(16762)

vim 删除指定的行

2015-5-3 杜世伟 Vim

vim 删除指定的行

#-----命令行模式下------

1.删除以#开头的行:    
g/^#.*$/d 
2.删除以//开头的行:    
g/^\/\/.*$/d
3.删除空白行:
g/^$/d
4.刪除包含有空格組成的空行
g/^\s*$/d
5.删除以空格或tab開頭到結尾的空行

g/^[ |\t]*$/d

原创转载请注明来源:https://www.dushiwei.cn/post/461

阅读全文>>

标签: linux vim

评论(0) 浏览(5334)

Powered by emlog 沪ICP备2023034538号-1