LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-28-2010, 04:18 AM   #1
samuel.m012
LQ Newbie
 
Registered: May 2010
Posts: 1

Rep: Reputation: 0
Linux bash I am writing shell scrip


#I'm getting "unexpected end of file"
# I'm trying to create a directory if the directory don't ."



targetroot=$1
destroot=$2
cleanup=$3

if [ -d "$targetroot" ]
then
echo "$targetroot file exists"
else
mkdir $targetroot
echo "new file is created"



allfiles=`ls -R $targetroot`
index=0

for file in $allfiles;
do
file=${file%:}
if [ -d $file ];
then
array[$index]=$file
index=$(( $index + 1))


fi
done
 
Old 05-28-2010, 04:21 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello and Welcome to LinuxQuestions,

You're missing a 'fi' after the done to close the first 'if'. Or is that a typo?

Kind regards,

Eric
 
Old 05-28-2010, 07:53 AM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,713
Blog Entries: 27

Rep: Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055
Hi,

Welcome to LQ!

Sure looks like homework to me!

'How to Ask Questions the Smart Way' would be one link you should look at to help us to help you in the future.

I won't be as nice as Eric. You should try to complete the task(s) yourself even if it's not homework. Step through the script singular, treat each step independent and paying attention to the results expected or errors then correct results accordingly. We will aid you when you help yourself to the solution. Provide us with what you have attempted along with the results/errors and then maybe someone will be able to assist.

Bash Reference Manual & Advanced Bash-Scripting Guide will provide you with some useful information. Hopefully the links will aid you to a solution and some helpful information to continue the learning experience.

Just a few more links to aid you;

Linux Documentation Project
Rute Tutorial & Exposition
Linux Command Guide
Utimate Linux Newbie Guide
LinuxSelfHelp
Getting Started with Linux
Linux Home Networking
Virtualiation- Top 10


The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
 
Old 05-28-2010, 07:59 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi onebuck,

I had my doubts about posting too, but looking at previous post of the OP I was under the impression that it might not be homework after all. If I believed it to be homework I wouldn't have posted a solution just like that

You are right though that OP should go through some documentation before even posting simple questions that normally are basic knowledge. But, I'm in a good mood today

Kind regards,

Eric
 
Old 05-28-2010, 08:39 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,713
Blog Entries: 27

Rep: Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055Reputation: 2055
Hi,

Eric, your just to nice.

My stance is that people should make some effort and sometimes that effort will require them to sweat a little. Burn the oil to gain some useful knowledge that will lead them to understanding rather than spoon feeding that will only provide immediate results instead of the means to continue. That is if they are willing to continue to learn. Then that person will put some of the required effort(s) to gain the knowledge that will lead to understanding. Desires??

Sure, things are easier for me now but that required effort to attain the knowledge. My continued effort and desire that my knowledge be extended is one of the driving forces in my life. As to the OP, I don't know his/her history here or elsewhere but my suggestions do pertain to the gainful situations that anyone/everyone should use. Add in a little curiosity to the mix then things will get interesting thus snowballing.
[/whatever off]

 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I cannot move a my file into my archives directory in my bash scrip Aubrey0406 Linux - Newbie 7 04-13-2010 06:01 AM
I want a linux-4 shell scrip that can retreive all the specified folders to_kami75 Linux - Software 1 12-22-2009 11:31 PM
[SOLVED] shell scrip to read ldap user details Buddhike G Linux - Software 4 05-24-2008 09:00 AM
while writing your own Bash shell command basak Linux - Software 4 08-02-2006 10:58 AM
got a syntax error which shows unexpected end of line when tried to run a shell scrip racer_mec Linux - Newbie 1 01-10-2005 01:43 AM


All times are GMT -5. The time now is 08:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration