I have to edit text file in android shell.
so I type this shell script.
but my Galaxy Nexus does not have Sed, Awk neither.
shell@android:/ $ sed -e "s/old_pattern/new_pattern/g" file_name > modify_file
/system/bin/sh: sed: not found
it doesn’t worked.
how can i modify old_pattern to new_pattern in text file.
is it possible in Shell Script?
Edited Shell Script
#!/system/bin/sh
ARGS=4
BAD=65
if [ $# -ne "$ARGS" ]
then
echo "Usage: `basename $0` TARGET_FILE,OLD_PATTERN,NEW_PATTERN,MODIFY_FILE"
exit $BAD
fi
old_pattern=$2
new_pattern=$3
modify_file=$4
if [ -f "$1" ]
then
target_file=$1
else
echo "\"$3\" Does not exist."
exit $BAD
fi
exit 0
Solution :
shell@android:/ $ while read STRING
>do
>echo "${STRING//old_pattern/new_pattern}" >> modify_file_name
>done < target_file_name
shell@android:/ $
It is possible with pure
bash, but it will be very slooow on big files.ps. Oh, I just mentioned that your shell isn’t
bash. Seems like it is justsh. That won’t work withsh.