Issue
I have created a bash script named call.sh
#!/bin/bash
termux-tts-speak whom doyou want to call
var="$(termux-speech-to-text)"
if [ "$var" = "Pappu" ]
then
termux-tts-speak calling to pappu
termux-telephony-call xxxxxxxxxx
elif [ "$var" = "call me" ]
then
termux-tts-speak calling to you
termux-telephony-call xxxxxxxxxx
else
termux-tts-speak sorry I can not understand say it again
fi
I runs the script using the command
$bash call.sh
But if I want to execute the script skipping first 3 line without modify the bash file. How can I do that help me please?
Solution
Use the tail
command and pipe it to bash
:
tail -n +4 call.sh | bash
But a better idea would be to use command-line arguments and test in the script.
#!/bin/bash
if [ "$1" != "--noask" ]
then
termux-tts-speak whom do you want to call
fi
var="$(termux-speech-to-text)"
if [ "$var" = "Pappu" ]
then
termux-tts-speak calling to pappu
termux-telephony-call xxxxxxxxxx
elif [ "$var" = "call me" ]
then
termux-tts-speak calling to you
termux-telephony-call xxxxxxxxxx
else
termux-tts-speak sorry I cannot understand say it again
fi
Then you can run the script like this to skip the first command:
./call.sh --noask
Answered By - Barmar Answer Checked By - Katrina (WPSolving Volunteer)