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 8386127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:50:58+00:00 2026-06-09T17:50:58+00:00

Having trouble trying to run this from bash : [root@bryanserver ~]# $SPACER=#——-# APACHE_ENABLED=`ls -1

  • 0

Having trouble trying to run this from bash :

[root@bryanserver ~]# $SPACER="#-------#" APACHE_ENABLED=`ls -1 "$HTTPD_HOSTS-EN" | grep ".conf" | sed s/.conf//` APACHE_COUNT=`echo -e "$APACHE_ENABLED" | wc -1` if [ -n "$APACHE_ENABLED" ]; then echo $SPACER echo "Apache enabled Sites: $APACHE_COUNT" echo "$APACHE_ENABLED" else echo $SPACER echo "There are no detectable nor delectable WebSites In Sight Blackbeard" fi
bash: syntax error near unexpected token `then

Is the problem with the code per se or with trying to use it from the shell
rather than having it in a file and sourcing the file?

Entering this on the command line in Bash :

APACHE_ENABLED=`"$HTTPD_HOSTS_EN" | grep ".conf" | sed s/.conf//`
APACHE_COUNT=`echo -e "$APACHE_ENABLED" | wc -l`
if [ -n "$APACHE_ENABLED" ]; then
 echo $SPACER
 echo "Apache Enabled Sites: $APACHE_COUNT"
 echo "$APACHE_ENABLED" 
else
 echo $SPACER
 echo "There are no detected Apache Enabled Sites"
fi

produces this output:
APACHE_ENABLED=`"$HTTPD_HOSTS_EN" | grep ".conf" | sed s/.conf//`
APACHE_COUNT=`echo -e "$APACHE_ENABLED" | wc -l`
-bash: : command not found
[root@bryanserver ~]# APACHE_COUNT=`echo -e "$APACHE_ENABLED" | wc -l`
[root@bryanserver ~]# if [ -n "$APACHE_ENABLED" ]; then
>  echo $SPACER
>  echo "Apache Enabled Sites: $APACHE_COUNT"
>  echo "$APACHE_ENABLED"
> else
>  echo $SPACER
>  echo "There are no detected Apache Enabled Sites"
> fi  #

and hit enter and voila! this is the result:
There are no detected Apache Enabled Sites
[root@bryanserver ~]#
and Bash is ready to do more work.

So, yes as Keith pointed out, I had mistaken an ell for a 1, and there are still some quirks, but it executes and issues a report. That’s progress.

I am working here with some material from Charles Smith; he shared some scripts on GitHub;
github.com/twohlix/HostingScripts/blob/master/listwww.

But I was using NotePad, and after editing some things, when I would put the text on the clipboard and unload it in Bash, what was I believe happening was I was getting the EOF issues. This SO question gave me an idea:
bash EOF in if statement
I used View / Show Line Endings in NotePad2, and copied my code, then pasted it
into Bash, that worked.

  • 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-06-09T17:51:00+00:00Added an answer on June 9, 2026 at 5:51 pm

    Things I see:

    • declaration of $SPACER shouldn’t have the dollar sign
    • add semicolons ; between declarative statements

    I think this is what you mean in a multi-line statement:

    SPACER="#-------#"
    APACHE_ENABLED=`ls -1 "$HTTPD_HOSTS-EN" | grep ".conf" | sed s/.conf//`
    APACHE_COUNT=`echo -e "$APACHE_ENABLED" | wc -1`
    if [ -n "$APACHE_ENABLED" ]; then 
        echo $SPACER;
        echo "Apache enabled Sites: $APACHE_COUNT";
        echo "$APACHE_ENABLED";
    else 
        echo $SPACER;
        echo "There are no detectable nor delectable WebSites In Sight Blackbeard";
    fi
    

    In one line then, remember to add semicolons or the double ampersand && to separate statements:

    SPACER="#-------#"; APACHE_ENABLED=`ls -1 "$HTTPD_HOSTS-EN" | grep ".conf" | sed s/.conf//`; APACHE_COUNT=`echo -e "$APACHE_ENABLED" | wc -1`; if [ -n "$APACHE_ENABLED" ]; then echo $SPACER; echo "Apache enabled Sites: $APACHE_COUNT"; echo "$APACHE_ENABLED"; else echo $SPACER; echo "There are no detectable nor delectable WebSites In Sight Blackbeard"; fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run the following query, and I'm having trouble with the wildcard.
I`m having trouble trying to optimize this query with OVER (PARTITION BY ...) because
i'm having trouble trying to define this function-like macro, which takes 4 vector magnitudes
I am having trouble trying to print a table from a webpage. When I
I am having trouble trying to put in data for this project I'm working
I am having trouble trying to get iterators for inner sub-containers. Basically imagine this
I'm new to android... having trouble trying to open a URL from a live
I'm having trouble with an Expect regular expression. I'm trying to match on this
I am having trouble trying to use an imported class from a jar file
I'm having trouble trying to get ValueInjector to map my objects correctly. This is

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.