2013-11-20 158 views
0

我想修剪adb中的字符串。 如果我寫busybox --help它會列出cut和sed作爲可用命令。在Android busybox中使用cut或sed

mount |grep -e /system 

作品,但

mount |grep -e /system| cut -f 1 -d ' ' 

不起作用。 Android的busybox中是否有特殊的語法? 我也試過

echo "Hello World"|cut -f 1 -d ' ' 
的手冊頁

,它不工作..

[email protected]:/ # busybox cut --help 
busybox cut --help 
BusyBox v1.21.1-Stericson (2013-07-08 15:58:11 BST) multi-call binary. 

Usage: cut [OPTIONS] [FILE]... 

Print selected fields from each input FILE to stdout 

    -b LIST Output only bytes from LIST 
    -c LIST Output only characters from LIST 
    -d CHAR Use CHAR instead of tab as the field delimiter 
    -s  Output only the lines containing delimiter 
    -f N Print only these fields 
    -n  Ignored 
+0

1 CH eck可用選項'cut --help' –

+0

爲問題增加了可用選項。 – PdXY

+0

只需將busybox添加到該行,它就可以工作。這是一樣的 '斬--help' 不起作用,但 'busybox的削減--help' 一樣。 'mount | grep -e/system | busybox cut -f 1 -d''' – PdXY

回答

1

爲了busybox小程序工作,你希望你首先需要創建相應的符號鏈接的方式:

$ adb shell whence sed 
$ adb shell sed 
/system/bin/sh: sed: not found 
$ adb root 
$ adb remount 
remount succeeded 
$ adb shell whence busybox 
/system/bin/busybox 
$ adb shell ln -s /system/bin/busybox /system/bin/sed 
$ adb shell whence sed 
/system/bin/sed 
$ adb shell sed 
Usage: sed [-efinr] SED_CMD [FILE]... 

或者只是做mount | grep -e /system | busybox cut -f 1 -d ' '

+0

是的,正如我在評論中說的那樣,錯誤確實是缺少符號鏈接。我沒有意識到,當我輸入「sed」或「cut」時沒有錯誤,它找到了命令並給了我參數列表。仍然我必須使用busybox命令而不是別名。感謝您的幫助! – PdXY