Unexpected end-of-file error (bash script) - need another pair of eyes.
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Unexpected end-of-file error (bash script) - need another pair of eyes.
I'm pretty much satisfied that all the i's have been dotted and the t's crossed, so far as if/fi, closed parentheses, in-out quotation marks and the like go. I just need another pair of eyes to be sure. My bash shell keeps insisting on there being a line 32 to this script, while nano, vim and the "cat foo.sh | wc -l" combo all agree with my GUI text editor (with which I wrote 98% of the script -- and yes it's been dos2unix'ed as well)-- there are only 31 lines!
Here's the script:
Code:
#!/bin/bash -x
echo -ne "Fixture Identification Fixer for Exiv2 - FIFE\n"
echo -ne "Please enter the name of the file you want to modify.\n"
read gfile
if [ -e $gfile ]
then
oldf1=$(exiv2 -PInv $gfile | grep 'FixtureId' | sed 's/^FixtureId[ ]*//')
echo -e "The word or phrase currently in this file reads: ${oldf1}.\n"
echo -ne "Do you want to change this Fixture ID to something else? y/n \n"
read yesorno
if [ $yesorno = "n" ]
then
echo -ne "No changes made to file ${gfile}\.\n"
else
echo "Are you sure? y/n "
read confirmm
if [ $confirmm = "n" ]
then
exit 1;
else
exiv2 -M"del Iptc.Application2.FixtureId" modify $gfile
echo -e "The old FixtureID has been removed."
echo -ne "Please enter the word or phrase to replace '$oldfi .'\n"
read newstringhx
exiv2 -M"add Iptc.Application2.FixtureId String $newstringhx" modify $gfile
sleep 1
echo -ne "The new phrase, \"$newstringhx\",\n has been written to file \033[37;40m${gfile}.\033[0m\n"
fi
fi
else
echo -e "Sorry, that file is not in this folder."
Hope someone finds something. No sweat off my knee if it was something I couldn't see (rhyme unintended).
I'm pretty much satisfied that all the i's have been dotted and the t's crossed, so far as if/fi, closed parentheses, in-out quotation marks and the like go. I just need another pair of eyes to be sure. My bash shell keeps insisting on there being a line 32 to this script, while nano, vim and the "cat foo.sh | wc -l" combo all agree with my GUI text editor (with which I wrote 98% of the script -- and yes it's been dos2unix'ed as well)-- there are only 31 lines!
Here's the script:
Code:
#!/bin/bash -x
echo -ne "Fixture Identification Fixer for Exiv2 - FIFE\n"
echo -ne "Please enter the name of the file you want to modify.\n"
read gfile
if [ -e $gfile ]
then
oldf1=$(exiv2 -PInv $gfile | grep 'FixtureId' | sed 's/^FixtureId[ ]*//')
echo -e "The word or phrase currently in this file reads: ${oldf1}.\n"
echo -ne "Do you want to change this Fixture ID to something else? y/n \n"
read yesorno
if [ $yesorno = "n" ]
then
echo -ne "No changes made to file ${gfile}\.\n"
else
echo "Are you sure? y/n "
read confirmm
if [ $confirmm = "n" ]
then
exit 1;
else
exiv2 -M"del Iptc.Application2.FixtureId" modify $gfile
echo -e "The old FixtureID has been removed."
echo -ne "Please enter the word or phrase to replace '$oldfi .'\n"
read newstringhx
exiv2 -M"add Iptc.Application2.FixtureId String $newstringhx" modify $gfile
sleep 1
echo -ne "The new phrase, \"$newstringhx\",\n has been written to file \033[37;40m${gfile}.\033[0m\n"
fi
fi
else
echo -e "Sorry, that file is not in this folder."
Hope someone finds something. No sweat off my knee if it was something I couldn't see (rhyme unintended).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.