發表文章

目前顯示的是 8月, 2017的文章

分辨Sparsed與一般Ext4 Image

Android image編譯出來的會用sparsed image儲存 AOSP內的產生sparse用的函式庫 https://android.googlesource.com/platform/system/core/+/master/libsparse/ 將sparse image轉換為raw image 程式碼位置: system/core/libsparse/simg2img.c AOSP編譯出來的路徑可能在out/host/linux-x86/bin 用法: simg2img {sparse_image_files} {raw_image_file} 將raw image轉換為sparse image 程式碼位置: system/core/libsparse/img2simg.c AOSP編譯出來的路徑可能在out/host/linux-x86/bin 用法: img2simg {raw_image_file} {sparse_image_file} [{block_size}]   網路上其他關於Sparsed image的Source Code: https://github.com/anestisb/android-simg2img 分辨Sparsed與一般Ext4 Image方法 使用file指令,如果是一般的ext4會顯示相關資訊 file system.raw system.raw: Linux rev 1.0 ext4 filesystem data, UUID=57f8f4bc-abf4-655f-bf67-946fc0f9f25b (extents) (large files) 但是file對於sparsed ext4無法顯示相關資訊 file system.ext4 system.ext4: data 有些系統會顯示相關資訊 system.ext4: Android sparse image, version: 1.0, Total of 262144 4096-byte output blocks in 1620 input chunks. 掛載Sparsed/Ext4 image到本機目錄 安裝simg2img工具 sudo apt-get install an

取代指定目下含有指定字串的內容

grep -rl {搜尋目標字串} {指定目錄} | xargs sed -i 's/{搜尋目標字串}/{取代的字串}/g' grep的-r是搜尋目錄 grep的-l是只印出含有搜尋目標字串的檔案 grep的搜尋目標字串要注意若含有regular expression的萬用字元,如(.)和(*)等,需要進行跳脫 例如: 把ALOG改成LOG grep -rl ALOG ./ | xargs sed -i 's/ALOG/LOG/g' 參考資料 http://vasir.net/blog/ubuntu/replace_string_in_multiple_files