note  正则表达式笔记

匹配数字字符串

1
'1000.12000'.match(/[-]?\d*(?:\d|[.]\d*[^.0])/)[0];  // 匹配数字字符串,用于去掉小数点结尾后 0, 同时兼容整数
note  Linux笔记

常用命令

新建

1
2
# 在当前目录下新建 test 文件夹
$mkdir test

查找

简单查找

1
2
3
4
5
6
7
8
9
$ls -l 
- 简写为ll -查看目录下文件

$less file
? 向上查找
/ 向下查找

n 使用查找后,跳到下个匹配位置
N 跳至上一个匹配位置

正则表达式搜索文件

1
2
3
4
5
6
7
8
9
$egrep -i -a1 'loadWithdrawalacc[a-zA-Z -]+0324'  2goportal.log
-i 忽略大小写
-b1 匹配前一行
-a1 包含被匹配后一行

egrep -i 'action.*K00660232' 2goportal.log > K00660232.log
-i 忽略大小写
* 匹配任意字符
> K00660232.log #意思是按前面的正则匹配出来的所有行,另存为一份文件(名称:K00660232.log)
1
2
3
4

su #进入root权限
exit #退出su 进入的root权限
su test #切换用户为 test

复制

1
2
3
4
5
6
Linux命令,复制文件夹
$cp -r MR BOUAT27
将 MR文件夹所有文件 复制到 BOUAT27(BOUAT27 不存在)

如果BOUAT27 已经存在
$cp -r MR/. BOUAT27

复制 A Linux 到 B Linux

1
2
3
4
linux 复制命令:scp -r user@remotehost:/home/backups /home/slynux
- 远程机A目录:user@remotehost:/home/backups
- 本机A 目录: /home/slynux
*从远程机目录A 复制到 本机 目录A,或者调换 目录,前后顺序,即从本机复制到远程机

压缩

ZIP

1
2
3
4
5
6
7
8
9
zip all.zip *.jpg   #将所有.jpg的文件压缩成一个zip包

unzip all.zip #将all.zip中的所有文件解压到当前目录中

unzip all.zip -d all #将all.zip 中的所有文件解压到当前目录中的all文件夹中

zip -r hy.zip hy #将当前目录下的hy文件夹压缩为hy.zip

zip -r hy.zip hy 123.txt #将当前目录下的hy文件夹和123.txt压缩为hy.zip

编辑

1
2
vi /test.txt
:%s/aaa/bbb/g #批量替换 aaa 为 bbb
note  [BUG] Cordova build
问题如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
D:\Levana2\MyApp>cordova build
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\levana.xue\AppData\Local\Android\Sdk (DEPRECATED)
Using Android SDK: C:\Users\levana.xue\AppData\Local\Android\Sdk
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/6.6.1/userguide/gradle_daemon.html
Process command line: D:\Levana.Xue\develop-tool\java-jdk\openjdk-8u41-b04-windows-i586-14_jan_2020\java-se-8u41-ri\bin\java.exe -Xmx2048m -Dfile.encoding=GBK -Duser.country=CN -Duser.language=zh -Duser.variant -cp D:\Levana.Xue\develop-tool\android-gradle\gradle-6.6.1\lib\gradle-launcher-6.6.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 6.6.1
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap


* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
Command failed with exit code 1: D:\Levana.Xue\develop-tool\android-gradle\gradle-6.6.1\bin\gradle.BAT -p D:\Levana2\MyApp\platforms\android wrapper -b D:\Levana2\MyApp\platforms\android\wrapper.gradle

原因

由于内存不够导致

解决方案

Your system can not provide enough continuous memory space for the jvm and causes the problem.

Here is what works for me:

Add an environment variable GRADLE_OPTS with the value of -Dorg.gradle.jvmargs=-Xmx512m

You can use -Xmx1g if you have more memory space available.

link:https://stackoverflow.com/questions/30384375/vm-error-while-build-cordova-phonegap