linux中输入输出的标准文件描述符
#!/bin/bash#linux中输入输出的标准文件描述符。
#linux将对象当做文件来处理,并用标准文件描述符来表示每个文件对象。每一个文件描述符都可以标识一个会话中打开的文件。
#每个过程中最多可以有9个文件描述符,其中前三个被bash shell指定用于特殊用途
#文件描述符 缩写 描述
#0 STDIN 标准输入
#1 STDOUT 标准输出
#2 STDERR 标准错误
#对于一个终端来讲,标准输入STDIN就是键盘、标准输出STDOUT和标准错误STDERR就是屏幕
#我们可以通过重定向符(<,>)来改变输入、输出和错误。
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]) #逆序截取,具体啥意思没搞明白?
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 wget 详解
wget是linux上的命令行的下载工具。这是一个GPL许可证下的自由软件。wget支持HTTP和FTP协议,支持代理服务器和断点续传功能,能够自动递归远程主机的目录,找到合乎条件的文件并将其下载到本地硬盘上;如果必要,wget将恰当地转换页面中的超级连接以在本地生成可浏览的镜像。由于没有交互式界面,wget可在后台运行,截获并忽略HANGUP信号,因此在用户推出登录以后,仍可继续运行。通常,wget用于成批量地下载Internet网站上的文件,或制作远程网站的镜像shell 算术运算操作
算术运算符指的是可以在程序中实现加、减、乘、除等数学运算的运算符。Shell中常用的数学运算符如下所示。
+:对两个变量做加法。
-:对两个变量做减法。
*:对两个变量做乘法。
/:对两个变量做除法。
**:对两个变量做幂运算。
%:取模运算,第一个变量除以第二个变量求余数。
+=:加等于,在自身基础上加第二个变量。
-=:减等于,在第一个变量的基础上减去第二个变量。
*=:乘等于,在第一个变量的基础上乘以第二个变量。
/=:除等于,在第一个变量的基础上除以第二个变量。
%=:取模赋值,第一个变量对第二个变量取模运算,再赋值给第一个变量。
Linux下安装 Memcached服务器端
#!/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 ..
./configure: error: SSL modules require the OpenSSL library
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
CentOS 7.0关闭默认防火墙启用iptables防火墙
操作系统环境: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
phpize Cannot find autoconf
Centos下执行phpize提示“Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this scrIPt.”原因:缺少autoconf
解决方法:
yum install autoconf
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
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(19)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(38)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(73)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(49)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)