Issue
I am trying to write a zsh script to check if a file contains specific string.
The difficulty I can't overcome is that the file is on Android device and I am executing the script on a Mac.
This is what I wrote (works if the file is on the Mac as well)
if grep -q SpecificString "Desktop/file.json"
then
echo found
else
echo not found
fi
Let's say that I want to check for SpecificString in a file on Android (storage/self/primary/file.json)
How could I do that?
Solution
One possible script might be the following:
#!/bin/zsh
adb shell grep "SpecificString" /sdcard/file.json
if [ $? -eq 0 ]; then
echo "string found"
else
echo "string not found"
fi
Of course you have to extend it according to your needs.
Answered By - Lino
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.