Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6066393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:29:46+00:00 2026-05-23T09:29:46+00:00

#!/bin/sh for i in {0..999} do if [$i lt 10] then nohup java BeginIndex

  • 0
#!/bin/sh

for i in {0..999}
do
    if [$i lt  10]
    then
            nohup java BeginIndex ~actors/00{$i} ~/index_new/ > ~/results/actors_results/00{$i}.txt
            echo "INDEXING ($i)th directory completed "
    elif [$i lt 100]; then
            nohup java BeginIndex ~/actors/0{$i} ~/index_new/ > ~/results/actors_results/0{$i}.txt
            echo "INDEXING ($i)th directory completed "

    else
            nohup java BeginIndex ~/actors/{$i} ~/index_new/ > ~/results/actors_results/{$i}.txt
            echo "INDEXING ($i)th directory completed "
    fi
done

Can anyone tell me what’s wrong with this script? do I need to do #!/bin/bash first? Also, can i nohup this script the way it’s written or do I have to remove the nohup in the if-else statements? I don’t really know all the syntax of if-else and for loops for bash… sorry if this is such a simple question. I appreciate the help!

Edit (posting an update from comments)

I’m trying to index a directory called actors, with 1000 subdirectories with files inside them. the java program will run, but it can’t handle all the files in these 1000 directories (about 1.8million). I want to write a script that will do it subdirectory at a time.

I’m ssh’ing into a server to do this, but it will take a while so I want it to not drop. I can’t just run the java program on the whole directory, because it runs out of heap memory. It’s not the most efficient java code, but I’m working on another solution to that problem while this script runs subdirectory-at-a-time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:29:47+00:00Added an answer on May 23, 2026 at 9:29 am

    The test command is definitely wrong.

    Just remember "[" in bash is a command, not a syntax. It expects the string "]" as the last argument. This is why spaces are required before and after them. (Semicolon is OK, because it is a part of the syntax)

    Also, as Kerrek pointed out, the comparation operator is -lt not lt.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/bin/bash if test $# == 4; then echo $*; else echo args-error >&2; fi;
#!/bin/bash if [ ! $1 ] then echo "no param" else set FAV_COLOR=$1 echo
#!/bin/sh files = 'ls /myDir/myDir2/myDir3/' for file in $files do echo $file java myProg
#!/bin/bash echo 'first line' >foo.xml echo 'second line' >>foo.xml I am a total newbie
With /bin/bash , how would I detect if a user has a specific directory
#/bin/bash PATH_GSUTIL= [ -f $PATH_GSUTIL/gsutil ] || (echo $PATH_GSUTIL does not contain 'gsutil' &&
#! /bin/bash echo Please input 2 nums: read a b if [ -z $b
#!/bin/sh #My script echo Are you sure you want to reorganize your files? echo
#!/bin/bash for ((var=0; var<20; var++)) do echo Number is: $(grep 'Multiple_Frame = echo **$var**'
/!bin/sh if [ "`echo $desc $status | awk -F"," '{print $3}' | awk -F"

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.