Linux入門(五) 本篇文章主要講述下文件處理相關的命令 1: 顯示許可權 ls -lh 總用量 36K drwxrwxr-x 5 zh zh 4.0K 2月 28 16:47 app -rw-rw-r-- 1 zh zh 530 2月 22 18:25 build.gradle drwxrwxr- ...
Linux入門(五)
本篇文章主要講述下文件處理相關的命令
1: 顯示許可權
ls -lh
總用量 36K
drwxrwxr-x 5 zh zh 4.0K 2月 28 16:47 app
-rw-rw-r-- 1 zh zh 530 2月 22 18:25 build.gradle
drwxrwxr-x 3 zh zh 4.0K 2月 22 18:25 gradle
-rw-rw-r-- 1 zh zh 1.1K 2月 26 08:58 gradle.properties
-rwxrw-r-- 1 zh zh 5.2K 2月 22 18:25 gradlew
-rw-rw-r-- 1 zh zh 2.3K 2月 22 18:25 gradlew.bat
-rw-rw-r-- 1 zh zh 452 2月 22 18:25 local.properties
-rw-rw-r-- 1 zh zh 43 2月 22 18:25 settings.gradle
2: 查看文件內容(一)
cat命令查看文件內容:
cat build.gradle
可以看到build.gradle的內容從第一個位元組開始正常輸出.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.2"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
而tac命令可以從最後一行反向查看.
tac build.gradle
} delete rootProject.buildDir
task clean(type: Delete) {
}
}
jcenter()
google()
repositories {
allprojects {
}
}
// in the individual module build.gradle files
// NOTE: Do not place your application dependencies here; they belong
classpath "com.android.tools.build:gradle:4.1.2"
dependencies {
}
jcenter()
google()
repositories {
buildscript {
// Top-level build file where you can add configuration options common to all sub-projects/modules.
3: 查看文件內容(二)
使用more命令查看文件內容:
more build.gradle
4: 按行查看文件內容
查看一個文件的前幾行可以使用head命令:
head -5 build.gradle
執行結果輸出build.gradle的前5行數據.
使用tail命令可以查看文件的最後幾行:
tail -5 build.gradle
5: 實時查看文件內容
tail -f 命令可以實時的監測文件變動
tail -f settings.gradle
include ':app'
rootProject.name = "WebTest"tail: settings.gradle:文件已截斷
include ':app'
rootProject.name = "WebTest"
rootProject.name = "WebTest"tail: settings.gradle:文件已截斷
include ':app'
rootProject.name = "WebTest"
rootProject.name = "WebTest"rootProject.name = "WebTest"tail: settings.gradle:文件已截斷
include ':app'
rootProject.name = "WebTest"
6: 文件內容查找
在文件中查找關鍵詞app:
grep app settings.gradle
在文件中查找以rootProject開始的辭彙:
grep ^rootProject settings.gradle
在文件查找所有包含數字的行:
grep [0-9] settings.gradle
忽略大小寫查找:
grep -i "web" settings.gradle
查找多個文件:
grep -i "rootProject" settings.gradle build.gradle
settings.gradle:rootProject.name = "WebTest"
settings.gradle: delete rootProject.buildDir
build.gradle: delete rootProject.buildDir
指定目錄查找(包含子目錄並且遞歸查找):
grep -r "xxxxx" app/
匹配到二進位文件 app/build/intermediates/dex/debug/mergeDexDebug/classes.dex
匹配到二進位文件 app/build/intermediates/javac/debug/classes/com/test/webtest/MainActivity.class
匹配到二進位文件 app/build/intermediates/javac/debug/classes/com/test/webtest/WebActivity$1.class
匹配到二進位文件 app/build/intermediates/javac/debug/classes/com/test/webtest/WebActivity.class
匹配到二進位文件 app/build/intermediates/external_libs_dex/debug/mergeExtDexDebug/classes.dex
匹配到二進位文件 app/build/intermediates/project_dex_archive/debug/out/com/test/webtest/MainActivity.dex
匹配到二進位文件 app/build/intermediates/project_dex_archive/debug/out/com/test/webtest/WebActivity.dex
匹配到二進位文件 app/build/intermediates/project_dex_archive/debug/out/com/test/webtest/WebActivity$1.dex
app/src/main/java/com/test/webtest/MainActivity.java: Log.i("xxxxx", "changeScreenOffTime: "+System.currentTimeMillis());
app/src/main/java/com/test/webtest/MainActivity.java: Log.i("xxxxx", "changeScreenOffTime: "+anInt);
app/src/main/java/com/test/webtest/WebActivity.java: Log.i("xxxxx", "handleMessage: " + num++);
app/src/main/java/com/test/webtest/WebActivity.java: Log.i("xxxxx", "getRandom: "+index);
本文由博客一文多發平臺 OpenWrite 發佈!