if statement: 'fi' unexpected
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I have made a shell with an if statment, all newline characters are LF (Linux), when i try to execute the shell, i get an "syntax error: 'fi' unexpected".
if [ "$(ls -A /storage/$SDCARD_DIR/Android/obb/*/)" ]; then
echo -n -e $Y'One of games folders on your external SDCard has been already movednnTo fix that:n- We back to main menun- Select rs option to restore a specifiq game file in your internal storagen- Try again to the ma option to move all your games files to your external sdcard'$N
clear && main_menu
else
echo -n -e $C"For info: it's necessary to forcing games apps to be closed"$N; sleep 8;
APPSNAMES=`for dirs in "$INTFOLD"; do printf '%sn' $dirs | sed -r -e 's//storage/emulated/0/Android/obb///' | awk -f. 'print $NF' | sed -r -e 's////'`
while printf '%sn' "$APPSNAMES" | while IFS= read -r line
do
if [ -z $(ps | grep "$line") ]; then
xargs kill
echo -n -e $Y'Game(s) app(s) has been closednReady for next step...'$N; sleep 4;
else
echo -n -e $C'No game run in background on your devicenNext step now..'$N; sleep 4;
fi
done
echo -n -e $B'Move all your games to your external SCard...'$N; sleep 5;
for D in `find /storage/emulated/0/Android/obb/ -maxdepth 1 -type d`
do cp -af $D $EXSDCARD
done
for F in `find /storage/emulated/0/Android/obb/ -type f`
do rm -f $F
done
for X in `find "$EXSDCARD" -type F`
do ln -s $X $EXSDCARD
done
echo -n -e $G'All OBB files are now moved to your sdcardnNB: You could even see files in your internal storage, but they are just linkedn'$N; sleep 7;
echo -n -e $B'Back to main menu...'$N; sleep 5;
main_menu
fi
I don't understand why i get this error, i would like to point out that i use this script on Android environment with Termux, Busybox and got root access.
I have already check several threads of users with the same issue but i don't find any error(s).
shell-script busybox
 |Â
show 1 more comment
up vote
0
down vote
favorite
I have made a shell with an if statment, all newline characters are LF (Linux), when i try to execute the shell, i get an "syntax error: 'fi' unexpected".
if [ "$(ls -A /storage/$SDCARD_DIR/Android/obb/*/)" ]; then
echo -n -e $Y'One of games folders on your external SDCard has been already movednnTo fix that:n- We back to main menun- Select rs option to restore a specifiq game file in your internal storagen- Try again to the ma option to move all your games files to your external sdcard'$N
clear && main_menu
else
echo -n -e $C"For info: it's necessary to forcing games apps to be closed"$N; sleep 8;
APPSNAMES=`for dirs in "$INTFOLD"; do printf '%sn' $dirs | sed -r -e 's//storage/emulated/0/Android/obb///' | awk -f. 'print $NF' | sed -r -e 's////'`
while printf '%sn' "$APPSNAMES" | while IFS= read -r line
do
if [ -z $(ps | grep "$line") ]; then
xargs kill
echo -n -e $Y'Game(s) app(s) has been closednReady for next step...'$N; sleep 4;
else
echo -n -e $C'No game run in background on your devicenNext step now..'$N; sleep 4;
fi
done
echo -n -e $B'Move all your games to your external SCard...'$N; sleep 5;
for D in `find /storage/emulated/0/Android/obb/ -maxdepth 1 -type d`
do cp -af $D $EXSDCARD
done
for F in `find /storage/emulated/0/Android/obb/ -type f`
do rm -f $F
done
for X in `find "$EXSDCARD" -type F`
do ln -s $X $EXSDCARD
done
echo -n -e $G'All OBB files are now moved to your sdcardnNB: You could even see files in your internal storage, but they are just linkedn'$N; sleep 7;
echo -n -e $B'Back to main menu...'$N; sleep 5;
main_menu
fi
I don't understand why i get this error, i would like to point out that i use this script on Android environment with Termux, Busybox and got root access.
I have already check several threads of users with the same issue but i don't find any error(s).
shell-script busybox
See the doublewhile
inwhile printf '%sn' "$APPSNAMES" | while IFS= read -r line
, only one of which has a correspondingdo
/done
.
â Stéphane Chazelas
Sep 25 at 10:54
5
yet another plug for shellcheck.net
â Jeff Schaller
Sep 25 at 10:56
When assigning toAPPSNAMES
you use afor
loop. This loop is never closed. Also see unix.stackexchange.com/questions/321697
â Kusalananda
Sep 25 at 10:56
There are a total of fivedo
in the code, but only fourdone
. At the same time, there are sixfor
orwhile
.
â Kusalananda
Sep 25 at 11:02
Thank you very much StéphaneChazelas , thanks Jeff Schaller for the website and Kusalananda for his fixs, effectivly some of my loops didn't have their done.
â Rom
Sep 25 at 11:27
 |Â
show 1 more comment
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have made a shell with an if statment, all newline characters are LF (Linux), when i try to execute the shell, i get an "syntax error: 'fi' unexpected".
if [ "$(ls -A /storage/$SDCARD_DIR/Android/obb/*/)" ]; then
echo -n -e $Y'One of games folders on your external SDCard has been already movednnTo fix that:n- We back to main menun- Select rs option to restore a specifiq game file in your internal storagen- Try again to the ma option to move all your games files to your external sdcard'$N
clear && main_menu
else
echo -n -e $C"For info: it's necessary to forcing games apps to be closed"$N; sleep 8;
APPSNAMES=`for dirs in "$INTFOLD"; do printf '%sn' $dirs | sed -r -e 's//storage/emulated/0/Android/obb///' | awk -f. 'print $NF' | sed -r -e 's////'`
while printf '%sn' "$APPSNAMES" | while IFS= read -r line
do
if [ -z $(ps | grep "$line") ]; then
xargs kill
echo -n -e $Y'Game(s) app(s) has been closednReady for next step...'$N; sleep 4;
else
echo -n -e $C'No game run in background on your devicenNext step now..'$N; sleep 4;
fi
done
echo -n -e $B'Move all your games to your external SCard...'$N; sleep 5;
for D in `find /storage/emulated/0/Android/obb/ -maxdepth 1 -type d`
do cp -af $D $EXSDCARD
done
for F in `find /storage/emulated/0/Android/obb/ -type f`
do rm -f $F
done
for X in `find "$EXSDCARD" -type F`
do ln -s $X $EXSDCARD
done
echo -n -e $G'All OBB files are now moved to your sdcardnNB: You could even see files in your internal storage, but they are just linkedn'$N; sleep 7;
echo -n -e $B'Back to main menu...'$N; sleep 5;
main_menu
fi
I don't understand why i get this error, i would like to point out that i use this script on Android environment with Termux, Busybox and got root access.
I have already check several threads of users with the same issue but i don't find any error(s).
shell-script busybox
I have made a shell with an if statment, all newline characters are LF (Linux), when i try to execute the shell, i get an "syntax error: 'fi' unexpected".
if [ "$(ls -A /storage/$SDCARD_DIR/Android/obb/*/)" ]; then
echo -n -e $Y'One of games folders on your external SDCard has been already movednnTo fix that:n- We back to main menun- Select rs option to restore a specifiq game file in your internal storagen- Try again to the ma option to move all your games files to your external sdcard'$N
clear && main_menu
else
echo -n -e $C"For info: it's necessary to forcing games apps to be closed"$N; sleep 8;
APPSNAMES=`for dirs in "$INTFOLD"; do printf '%sn' $dirs | sed -r -e 's//storage/emulated/0/Android/obb///' | awk -f. 'print $NF' | sed -r -e 's////'`
while printf '%sn' "$APPSNAMES" | while IFS= read -r line
do
if [ -z $(ps | grep "$line") ]; then
xargs kill
echo -n -e $Y'Game(s) app(s) has been closednReady for next step...'$N; sleep 4;
else
echo -n -e $C'No game run in background on your devicenNext step now..'$N; sleep 4;
fi
done
echo -n -e $B'Move all your games to your external SCard...'$N; sleep 5;
for D in `find /storage/emulated/0/Android/obb/ -maxdepth 1 -type d`
do cp -af $D $EXSDCARD
done
for F in `find /storage/emulated/0/Android/obb/ -type f`
do rm -f $F
done
for X in `find "$EXSDCARD" -type F`
do ln -s $X $EXSDCARD
done
echo -n -e $G'All OBB files are now moved to your sdcardnNB: You could even see files in your internal storage, but they are just linkedn'$N; sleep 7;
echo -n -e $B'Back to main menu...'$N; sleep 5;
main_menu
fi
I don't understand why i get this error, i would like to point out that i use this script on Android environment with Termux, Busybox and got root access.
I have already check several threads of users with the same issue but i don't find any error(s).
shell-script busybox
shell-script busybox
edited Sep 25 at 11:08
Vlastimil
6,8411149123
6,8411149123
asked Sep 25 at 10:50
Rom
113
113
See the doublewhile
inwhile printf '%sn' "$APPSNAMES" | while IFS= read -r line
, only one of which has a correspondingdo
/done
.
â Stéphane Chazelas
Sep 25 at 10:54
5
yet another plug for shellcheck.net
â Jeff Schaller
Sep 25 at 10:56
When assigning toAPPSNAMES
you use afor
loop. This loop is never closed. Also see unix.stackexchange.com/questions/321697
â Kusalananda
Sep 25 at 10:56
There are a total of fivedo
in the code, but only fourdone
. At the same time, there are sixfor
orwhile
.
â Kusalananda
Sep 25 at 11:02
Thank you very much StéphaneChazelas , thanks Jeff Schaller for the website and Kusalananda for his fixs, effectivly some of my loops didn't have their done.
â Rom
Sep 25 at 11:27
 |Â
show 1 more comment
See the doublewhile
inwhile printf '%sn' "$APPSNAMES" | while IFS= read -r line
, only one of which has a correspondingdo
/done
.
â Stéphane Chazelas
Sep 25 at 10:54
5
yet another plug for shellcheck.net
â Jeff Schaller
Sep 25 at 10:56
When assigning toAPPSNAMES
you use afor
loop. This loop is never closed. Also see unix.stackexchange.com/questions/321697
â Kusalananda
Sep 25 at 10:56
There are a total of fivedo
in the code, but only fourdone
. At the same time, there are sixfor
orwhile
.
â Kusalananda
Sep 25 at 11:02
Thank you very much StéphaneChazelas , thanks Jeff Schaller for the website and Kusalananda for his fixs, effectivly some of my loops didn't have their done.
â Rom
Sep 25 at 11:27
See the double
while
in while printf '%sn' "$APPSNAMES" | while IFS= read -r line
, only one of which has a corresponding do
/done
.â Stéphane Chazelas
Sep 25 at 10:54
See the double
while
in while printf '%sn' "$APPSNAMES" | while IFS= read -r line
, only one of which has a corresponding do
/done
.â Stéphane Chazelas
Sep 25 at 10:54
5
5
yet another plug for shellcheck.net
â Jeff Schaller
Sep 25 at 10:56
yet another plug for shellcheck.net
â Jeff Schaller
Sep 25 at 10:56
When assigning to
APPSNAMES
you use a for
loop. This loop is never closed. Also see unix.stackexchange.com/questions/321697â Kusalananda
Sep 25 at 10:56
When assigning to
APPSNAMES
you use a for
loop. This loop is never closed. Also see unix.stackexchange.com/questions/321697â Kusalananda
Sep 25 at 10:56
There are a total of five
do
in the code, but only four done
. At the same time, there are six for
or while
.â Kusalananda
Sep 25 at 11:02
There are a total of five
do
in the code, but only four done
. At the same time, there are six for
or while
.â Kusalananda
Sep 25 at 11:02
Thank you very much StéphaneChazelas , thanks Jeff Schaller for the website and Kusalananda for his fixs, effectivly some of my loops didn't have their done.
â Rom
Sep 25 at 11:27
Thank you very much StéphaneChazelas , thanks Jeff Schaller for the website and Kusalananda for his fixs, effectivly some of my loops didn't have their done.
â Rom
Sep 25 at 11:27
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
0
down vote
The only think I don't like (can see is wrong) is
while printf '%sn' "$APPSNAMES" | while IFS= read -r line
Two whiles and only one do+done
Thefor dirs in "$INTFOLD"
also has nodone
â Stéphane Chazelas
Sep 25 at 11:27
Thank you @Alexander it works now.
â Rom
Sep 25 at 19:15
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The only think I don't like (can see is wrong) is
while printf '%sn' "$APPSNAMES" | while IFS= read -r line
Two whiles and only one do+done
Thefor dirs in "$INTFOLD"
also has nodone
â Stéphane Chazelas
Sep 25 at 11:27
Thank you @Alexander it works now.
â Rom
Sep 25 at 19:15
add a comment |Â
up vote
0
down vote
The only think I don't like (can see is wrong) is
while printf '%sn' "$APPSNAMES" | while IFS= read -r line
Two whiles and only one do+done
Thefor dirs in "$INTFOLD"
also has nodone
â Stéphane Chazelas
Sep 25 at 11:27
Thank you @Alexander it works now.
â Rom
Sep 25 at 19:15
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The only think I don't like (can see is wrong) is
while printf '%sn' "$APPSNAMES" | while IFS= read -r line
Two whiles and only one do+done
The only think I don't like (can see is wrong) is
while printf '%sn' "$APPSNAMES" | while IFS= read -r line
Two whiles and only one do+done
answered Sep 25 at 11:24
Alexander
86213
86213
Thefor dirs in "$INTFOLD"
also has nodone
â Stéphane Chazelas
Sep 25 at 11:27
Thank you @Alexander it works now.
â Rom
Sep 25 at 19:15
add a comment |Â
Thefor dirs in "$INTFOLD"
also has nodone
â Stéphane Chazelas
Sep 25 at 11:27
Thank you @Alexander it works now.
â Rom
Sep 25 at 19:15
The
for dirs in "$INTFOLD"
also has no done
â Stéphane Chazelas
Sep 25 at 11:27
The
for dirs in "$INTFOLD"
also has no done
â Stéphane Chazelas
Sep 25 at 11:27
Thank you @Alexander it works now.
â Rom
Sep 25 at 19:15
Thank you @Alexander it works now.
â Rom
Sep 25 at 19:15
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471293%2fif-statement-fi-unexpected%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
See the double
while
inwhile printf '%sn' "$APPSNAMES" | while IFS= read -r line
, only one of which has a correspondingdo
/done
.â Stéphane Chazelas
Sep 25 at 10:54
5
yet another plug for shellcheck.net
â Jeff Schaller
Sep 25 at 10:56
When assigning to
APPSNAMES
you use afor
loop. This loop is never closed. Also see unix.stackexchange.com/questions/321697â Kusalananda
Sep 25 at 10:56
There are a total of five
do
in the code, but only fourdone
. At the same time, there are sixfor
orwhile
.â Kusalananda
Sep 25 at 11:02
Thank you very much StéphaneChazelas , thanks Jeff Schaller for the website and Kusalananda for his fixs, effectivly some of my loops didn't have their done.
â Rom
Sep 25 at 11:27