笔记

"markdown.styles": [
        "E:\VS_code\Github\css\purple.css"
    ]
  • 替换字符串: sed 's/book/books/g' file
  • 选各目录下用例列表
#!/bin/sh

module=local_index
test="scripts/$module/"
test1=scripts/$module
ls -l $test1 | awk '{print $9}'|sed 1d > log1.log
sed "s/^/"$test"&/g" log1.log

  

【Linux】1. vi模式下"/"搜索,需要转义的符号:

       /$

       //

       /~

       /^

       /.

1. 批量修改不同文件中的同一字符串

sed -i "s/oldString/newString/g" `grep oldString -rl /path`

2. 各种变量类型占用的内存空间

          存储大小     例值     注释

byte      1byte        3      字节

int       4bytes       3      整数

short     2bytes       3      短整数

long      8bytes       3      长整数

float     4bytes     1.2      单精度浮点数

double    8bytes     1.2      双精度浮点数

char      2bytes     'a'      字符

boolean   1bit      true      布尔值

 3. Valgrind工具使用方法

http://blog.csdn.net/longbei9029/article/details/55252526?locationNum=3&fps=1

4. 判断shell中的字符串是否为数字: 

echo $test1| awk '{print($0~/^[-]?([0-9])+[.]?([0-9])+$/)?"number":"string"}'

5. bash shell 变量 数学运算

#!/bin/bash

test=`cat 0331.log | sed -n '3p'`
test1=`cat 0331.log | sed -n '2p'`
te=`echo "$test+$test1" | bc`;
echo "3DN tocal sum : $te";
 1 /*取得当前目录下的文件个数*/ 
 2 
 3 
 4 #include <stdio.h> 
 5 #include <stdlib.h> 
 6 #include <errno.h> 
 7 #include <sys/wait.h> 
 8 #include <string.h>
 9 
10 #define MAXLINE 1024 
11 
12 int main() 
13 { 
14 
15     char result_buf[3], command[MAXLINE]; 
16     char buf[4];
17     int rc = 0; // 用于接收命令返回值 
18     FILE *fp; 
19 
20     /*将要执行的命令写入buf*/ 
21     snprintf(command, sizeof(command), "cd ~/Linux_learn/ABC;cat test.txt"); 
22     //snprintf(command, sizeof(command), "ls ./ | wc -l"); 
23 
24     /*执行预先设定的命令,并读出该命令的标准输出*/ 
25     fp = popen(command, "r"); 
26     if(NULL == fp) 
27     { 
28         perror("popen执行失败!"); 
29         exit(1); 
30     } 
31 
32     while(fgets(result_buf, sizeof(result_buf), fp) != NULL) 
33     { 
34         /*为了下面输出好看些,把命令返回的换行符去掉 */
35         if('
' == result_buf[strlen(result_buf)-1]) 
36         { 
37             result_buf[strlen(result_buf)-1] = ''; 
38         } 
39         
40         //printf("命令【%s】 输出【%s】
", command, result_buf); 
41         buf[0] = result_buf[0];
42         printf("%s", &result_buf[0]); 
43         //printf("%s
", &buf[0]); 
44     } 
45 
46     if(result_buf=="1.0
")
47     {
48         printf("111111
");
49     }
50     if(&result_buf[0]=="1.0")
51     {
52         printf("111111
");
53     }
54     if(result_buf=="2.0")
55     {
56         printf("22222
");
57     }
58     else
59     {
60         printf("33333
");
61     }
62     
63 /*
64     rc = pclose(fp);   //等待命令执行完毕并关闭管道及文件指针
65     if(-1 == rc) 
66     { 
67         perror("关闭文件指针失败"); 
68         exit(1); 
69     } 
70     else 
71     { 
72         //printf("命令【%s】子进程结束状态【%d】命令返回值【%d】
", command, rc, WEXITSTATUS(rc)); 
73         printf("
"); 
74     } 
75 */    
76     return 0; 
77 }
原文地址:https://www.cnblogs.com/xinzi7/p/6504606.html