grep recursively / #63

Open
opened 2026-04-26 19:00:51 +02:00 by Benjamin_Loison · 2 comments
Owner

On my Fairphone 4 LineageOS 23.2:

grep --help
Output:
Toybox 0.8.12-android multicall binary (see toybox --help)

usage: grep [-abcEFHhIiLlnoqrsvwxZz] [-ABC NUM] [-m MAX] [-e REGEX]... [-MS PATTERN]... [-f REGFILE]... [FILE]...

Show lines matching regular expressions. If no -e, first argument is
regular expression to match. With no files (or "-" filename) read stdin.
Returns 0 if matched, 1 if no match found, 2 for command errors.

-e  Regex(es) to match.       -f  File(s) of regexes to match (1 per line).

file search:
-r  Recurse into subdirs     -R  Recurse following symlinks
-M  Match files (--include)  -S  Skip files (--exclude)
-I  Ignore binary files      --exclude-dir=PATTERN  Skip directories

match type:
-A  Show NUM lines after     -B  Show NUM lines before match
-C  NUM lines context (A+B)  -E  extended regex syntax
-F  fixed (literal match)    -a  always text (not binary)
-i  case insensitive         -m  match MAX many lines
-v  invert match             -w  whole word (implies -E)
-x  whole line               -z  input NUL terminated

display modes: (default: matched line)
-L  filenames with no match  -Z  output is NUL terminated
-c  count of matching lines  -l  filenames with a match
-o  only matching part       -q  quiet (errors only)
-s  silent (no error msg)

output prefix (default: filename if checking more than 1 file)
-H  force filename           -b  byte offset of match
-h  hide filename            -n  line number of match

Would help figure out where textually something is stored.

On my Fairphone 4 LineageOS 23.2: ```bash grep --help ``` <details> <summary>Output:</summary> ``` Toybox 0.8.12-android multicall binary (see toybox --help) usage: grep [-abcEFHhIiLlnoqrsvwxZz] [-ABC NUM] [-m MAX] [-e REGEX]... [-MS PATTERN]... [-f REGFILE]... [FILE]... Show lines matching regular expressions. If no -e, first argument is regular expression to match. With no files (or "-" filename) read stdin. Returns 0 if matched, 1 if no match found, 2 for command errors. -e Regex(es) to match. -f File(s) of regexes to match (1 per line). file search: -r Recurse into subdirs -R Recurse following symlinks -M Match files (--include) -S Skip files (--exclude) -I Ignore binary files --exclude-dir=PATTERN Skip directories match type: -A Show NUM lines after -B Show NUM lines before match -C NUM lines context (A+B) -E extended regex syntax -F fixed (literal match) -a always text (not binary) -i case insensitive -m match MAX many lines -v invert match -w whole word (implies -E) -x whole line -z input NUL terminated display modes: (default: matched line) -L filenames with no match -Z output is NUL terminated -c count of matching lines -l filenames with a match -o only matching part -q quiet (errors only) -s silent (no error msg) output prefix (default: filename if checking more than 1 file) -H force filename -b byte offset of match -h hide filename -n line number of match ``` </details> Would help figure out where textually something is stored.
Author
Owner
grep -riIl 'e' /sdcard/                                                                                                           
Output:
/sdcard/Android/data/org.videolan.vlc/files/vlc_crash_20260408_184425.log
/sdcard/Android/data/org.videolan.vlc/files/vlc_logcat_20260408_184425.log
...
130|FP4:/ # grep -riI 'e' /                                                                                                               
grep: /cache: Is a directory
grep: /dev/wlan: Invalid argument
grep: /dev/gpiochip6: Invalid argument
grep: /dev/wwan_ioctl: Invalid argument
grep: /dev/ipa_tethering_bridge: Invalid argument
grep: /dev/ipaIpv6CTTable: Invalid argument
grep: /dev/ipaNatTable: Invalid argument
grep: /dev/ffs-diag-2/ep0: File descriptor in bad state
grep: /dev/ffs-diag-1/ep0: File descriptor in bad state
grep: /dev/ffs-diag/ep0: File descriptor in bad state
grep: /dev/usb-ffs/ptp/ep3: Try again
grep: /dev/usb-ffs/ptp/ep2: Try again
benjamin_loison@benjamin-loison-framework:~$
grep -rI 'PART_OF_ADDRESS' / --exclude-dir={dev,sys,vendor,debug_ramdisk}                                                             
Output:
grep: /cache: Is a directory
grep: /storage/emulated: Permission denied
grep: /storage/self/primary: Is a directory
grep: /etc: Is a directory
grep: /vendor_dlkm/etc: Is a directory
grep: /d: Bad file descriptor
grep: /adb_keys: Bad file descriptor
grep: /system/vendor: Is a directory
grep: /system/usr/icu: Is a directory
grep: /system/system_ext: Is a directory
grep: /system/product: Is a directory
grep: /bugreports: Is a directory
/data_mirror/data_de/null/0/com.android.emergency/shared_prefs/com.android.emergency_preferences.xml:    <string name="address">CENSORED XXXXX France</string>

Using a virtual machine to make the search faster can help.

```bash grep -riIl 'e' /sdcard/ ``` <details> <summary>Output:</summary> ``` /sdcard/Android/data/org.videolan.vlc/files/vlc_crash_20260408_184425.log /sdcard/Android/data/org.videolan.vlc/files/vlc_logcat_20260408_184425.log ... ``` </details> ``` 130|FP4:/ # grep -riI 'e' / grep: /cache: Is a directory grep: /dev/wlan: Invalid argument grep: /dev/gpiochip6: Invalid argument grep: /dev/wwan_ioctl: Invalid argument grep: /dev/ipa_tethering_bridge: Invalid argument grep: /dev/ipaIpv6CTTable: Invalid argument grep: /dev/ipaNatTable: Invalid argument grep: /dev/ffs-diag-2/ep0: File descriptor in bad state grep: /dev/ffs-diag-1/ep0: File descriptor in bad state grep: /dev/ffs-diag/ep0: File descriptor in bad state grep: /dev/usb-ffs/ptp/ep3: Try again grep: /dev/usb-ffs/ptp/ep2: Try again benjamin_loison@benjamin-loison-framework:~$ ``` </details> ```bash grep -rI 'PART_OF_ADDRESS' / --exclude-dir={dev,sys,vendor,debug_ramdisk} ``` <details> <summary>Output:</summary> ``` grep: /cache: Is a directory grep: /storage/emulated: Permission denied grep: /storage/self/primary: Is a directory grep: /etc: Is a directory grep: /vendor_dlkm/etc: Is a directory grep: /d: Bad file descriptor grep: /adb_keys: Bad file descriptor grep: /system/vendor: Is a directory grep: /system/usr/icu: Is a directory grep: /system/system_ext: Is a directory grep: /system/product: Is a directory grep: /bugreports: Is a directory /data_mirror/data_de/null/0/com.android.emergency/shared_prefs/com.android.emergency_preferences.xml: <string name="address">CENSORED XXXXX France</string> ``` </details> Using a virtual machine to make the search faster can help.
Author
Owner
It helps [Benjamin_Loison/Backup_Android_apps/issues/43#issuecomment-13795079](https://codeberg.org/Benjamin_Loison/Backup_Android_apps/issues/43#issuecomment-13795079).
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/adb#63