`
文章列表
Bash字符串处理(与Java对照) - 20.查找子串的位置 In Java String.indexOf  int     indexOf(String str)           返回第一次出现的指定子字符串在此字符串中的索引。  int     indexOf(String str, int fromIndex)           从指定的索引处开始,返回第一次出现的指定子字符串在此字符串中的索引。    int     lastIndexOf(String str)           返回在此字符串中最右边出现的指定子字符串的索引。 ...
Bash字符串处理(与Java对照) - 19.查找字符的位置 In Java String.indexOf & String.lastIndexOf  int     indexOf(int ch)           返回指定字符在此字符串中第一次出现处的索引。  int     indexOf(int ch, int fromIndex)           从指定的索引开始搜索,返回在此字符串中第一次出现指定字符处的索引。   int     lastIndexOf(int ch)           返回最后一次出现的指定字符在此字符串 ...
Bash字符串处理(与Java对照) - 18.格式化字符串 In Java class Formatter 参见:http://download.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax   String.format static String     format(String format, Object... args)           使用指定的格式字符串和参数返回一个格式化字符串。     参见:String.format函数使用方法介绍 http://blog.cs ...
POSIX.2正则表达式说明 关于在Linux/Bash中正则表达式(POSIX.2 regular expressions)的语法形式,可以使用 man 7 regex 去查看。 Advanced Bash-Scripting Guide: 18.1. A Brief Introduction to Regular Expressions 写道 An expression is a string of characters. Those characters having an interpretation above and beyond their literal m ...
导入MySQL数据库模式及数据的Bash脚本(改进版本) 本文链接:http://codingstandards.iteye.com/blog/1190349   Bash脚本:import_db.sh #!/bin/bash # 脚本:import_db.sh # # v1: 2006-12-04 # v2: 2011-10-08/09 # v3: 2011-10-12 support for .tar.gz or .tgz # # 数据库连接参数 DBOPTS="-psunrise --default-character-set=gb ...
导入MySQL数据库模式及数据的Bash脚本 本文链接:http://codingstandards.iteye.com/blog/1189275   注:本文有了改进版本,见 http://codingstandards.iteye.com/blog/1190349   Bash脚本:import_db.sh #!/bin/sh # 脚本:import_db.sh # # v1: 2006-12-04 # v2: 2011-10-08/09 # # # 数据库连接参数 # TODO: 修改参数以适用具体的数据库环境 DBOPTS="- ...
导出MySQL数据库模式及数据的Bash脚本 本文链接:http://codingstandards.iteye.com/blog/1188375   Bash脚本文件:export_db.sh   #!/bin/sh # export_db.sh # 导出数据库模式及数据 # codingstandards@gmail.com # v1: 2010-05-23 # v2: 2011-10-08/09 # 命令使用说明 # 从标准输入读取数据库名称和表名称 # usage: export_db.sh # usage: export_db.sh - ...
Bash字符串处理(与Java对照) - 17.判断是否以另外的字符串结尾 In Java String.endsWith oolean     endsWith(String suffix)           测试此字符串是否以指定的后缀结束。   StringUtils.endsWith & StringUtils.endsWithIgnoreCase & StringUtils.endsWithAny org.apache.commons.lang.StringUtils endsWith方法 写道 public static boolean ...
Bash字符串处理(与Java对照) - 16.判断是否以另外的字符串开头 In Java String.startsWith  boolean     startsWith(String prefix)           测试此字符串是否以指定的前缀开始。  boolean     startsWith(String prefix, int toffset)           测试此字符串是否以指定前缀开始,该前缀以指定索引开始。相当于 this.substring(toffset).startsWith(prefix)   StringUtils. ...
问:在Linux下怎么用Bash判断是否存在某种模式的文件名? 比如,用脚本判断是否有 *_codec.* 形式的文件名,或者有 *.gif 形式的文件名。   答: 方法一: [ "$(ls *.gif 2>/dev/null)" ] && echo "*.gif exists" || echo "*.gif not exists" 方法二: exists_pattern_files(){     [ -e "$1" ] } ...
Bash字符串处理(与Java对照) - 15.计算子串出现的次数 In Java StringUtils.countMatches org.apache.commons.lang.StringUtils countMatches方法 写道 public static int countMatches(String str, String sub) Counts how many times the substring appears in the larger String. A null or empty ("") String ...
Bash字符串处理(与Java对照) - 14.判断是否包含另外的字符串(多达6种方法) In Java String.contains & String.indexOf String.contains方法只能判断是否包含某个子串,不能判断是否包含单个字符(当然能判断是否包含单个字符的子串) boolean     contains(CharSequence s)           当且仅当此字符串包含 char 值的指定序列时,才返回 true。   使用String.indexOf方法判断是否包含某个字符 int     indexOf(int ch) ...
Bash字符串处理(与Java对照) - 13.字符串数组连接(以指定分隔符合并) In Java 以指定的分隔符将字符串数组连接成一个字符串的源码 以下代码来自:http://www.oschina.net/code/explore/jsoup-1.4.1/helper/StringUtil.java /*** * Join a collection of strings by a seperator * @param strings collection of string objects * @param sep string t ...
E138: 不能写入 viminfo 文件 /root/.viminfo   前几天在使用vi编辑文件后,退出时报错:E138: 不能写入 viminfo 文件 /root/.viminfo!   搜索了一下网络,得到解决办法:删除~/.viminf*.tmp文件   在执行 rm -f ~/.viminf*.tmp 后 问题解决。   关于此问题,以及 ~/.viminfo 文件的说明参见: Chasfer Peng http://www.cublog.cn/u1/58186/showart_1798247.html    
一台工控机上安装了 WindowsXP 和 RHEL5.4 双系统,采用 GRUB 作为系统引导管理器。先安装WindowsXP,再安装Linux,GRUB会自动生成系统引导配置文件 /boot/grub/grub.conf。下面是配置文件的实际内容:   文件:/boot/grub/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot pa ...
Global site tag (gtag.js) - Google Analytics