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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:30:05+00:00 2026-06-15T13:30:05+00:00

Here’s a query string in a bash script that I wrote. SELECT day,xxx,yyy,zzz,if(count>$threshold,keyword,’_other’) as

  • 0

Here’s a query string in a bash script that I wrote.

“SELECT day,xxx,yyy,zzz,if(count>$threshold,keyword,’_other’) as keyword, sum(count) as searches
FROM
(SELECT
LEFT(FORMAT_UTC_USEC(UTC_USEC_TO_DAY(timestamp*1000000)),10) as day,
xxx, yyy, zzz,
REGEXP_EXTRACT(actiondata,’wvq=([^&])’) as keyword,
COUNT(
) as count
FROM [table.$dir_prefix]
WHERE product=’myproduct’
AND LEFT(FORMAT_UTC_USEC(timestamp*1000000),10) = ‘$1′
AND REGEXP_MATCH(actiondata,’wvq=’)
GROUP BY day,xxx, yyy,zzz,keyword
)
GROUP BY day,xxx,yyy,zzz, keyword

ORDER BY searches DESC;”


When I echo this string, the output is:

“SELECT day,xxx,yyy,zzz,if(count>50,keyword,’_other’) as keyword, sum(count) as searches
FROM
(SELECT
LEFT(FORMAT_UTC_USEC(UTC_USEC_TO_DAY(timestamp*1000000)),10) as day,
xxx, yyy, zzz,
REGEXP_EXTRACT(actiondata,’wvq=([^&])’) as keyword,
COUNT(
) as count
FROM 1
WHERE product=’myproduct’
AND LEFT(FORMAT_UTC_USEC(timestamp*1000000),10) = ‘2012-11-28′
AND REGEXP_MATCH(actiondata,’wvq=’)
GROUP BY day,xxx, yyy,zzz,keyword
)
GROUP BY day,xxx,yyy,zzz, keyword

ORDER BY searches DESC;”


Isolating the string and echoing “[table.$dir_prefix]” outputs the expected string, [table.20121128]. Can anyone explain why this is being evaluated in the larger string as ‘1’?

Escaping the square brackets (\[table.$dir_prefix\]) does not solve the problem.

More details:
$dir_prefix and $threshold are set to 20121128 and 50, respectively.
The string is being set like so:

to_echo=\
"SELECT day,xxx,yyy,zzz,if(count>$threshold,keyword,'_other') as keyword, sum(count) as searches FROM (SELECT LEFT(FORMAT_UTC_USEC(UTC_USEC_TO_DAY(timestamp*1000000)),10) as day, xxx, yyy, zzz, REGEXP_EXTRACT(actiondata,'wvq=([^&])') as keyword, COUNT() as count FROM [table.$dir_prefix] WHERE product='myproduct' AND LEFT(FORMAT_UTC_USEC(timestamp*1000000),10) = '$1' AND REGEXP_MATCH(actiondata,'wvq=') GROUP BY day,xxx, yyy,zzz,keyword ) GROUP BY day,xxx,yyy,zzz, keyword

ORDER BY searches DESC;"

Update 2

The script only has the issue on this specific server (running Ubuntu). My other server (running Redhat) does not have the problem and outputs what’s expected. It must be something configuration related. I can work around it but I really just want to know what’s behind this.

Here’s the exact script:

#!/bin/bash

dir_prefix=`date --date "$1" +%Y%m%d`;
threshold=$2;

query="SELECT day,xxx,yyy,zzz,if(count>$threshold,keyword,'_other') as keyword, sum(count) as searches FROM (SELECT LEFT(FORMAT_UTC_USEC(UTC_USEC_TO_DAY(timestamp*1000000)),10) as day, xxx, yyy, zzz, REGEXP_EXTRACT(actiondata,'wvq=([^&])') as keyword, COUNT() as count FROM [table.$dir_prefix] WHERE product='myproduct' AND LEFT(FORMAT_UTC_USEC(timestamp*1000000),10) = '$1' AND REGEXP_MATCH(actiondata,'wvq=') GROUP BY day,xxx, yyy,zzz,keyword ) GROUP BY day,xxx,yyy,zzz, keyword

ORDER BY searches DESC;"

echo $query;

Solution: More Info

Here’s a good write-up that goes into detail on preventing globbing when you don’t want it. I went with the set -f option.

http://blog.edwards-research.com/2011/05/preventing-globbing/

  • 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-15T13:30:06+00:00Added an answer on June 15, 2026 at 1:30 pm

    You have a file named 1 in the current directory, and it’s being globbed.

    $ touch 1
    $ echo [foo.123]
    1
    $ echo [foo.234]
    [foo.234]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the issue I am having: I have a large query that needs
here is the code i execute... dc.rs = dc.st.executeQuery(select count(*) from Accounts where date_join
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is the problem that I am trying to solve. I have two folders
Here is my scenario. I have a website running under AppPool1 and that works
Here is my error(if you need any more info just ask)- Error SQL query:

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.