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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:15:16+00:00 2026-06-09T14:15:16+00:00

This is my below shell script which I am using to query the hive

  • 0

This is my below shell script which I am using to query the hive tables and I saved this file as test4.sh

#!/bin/bash

DATE_YEST_FORMAT1=`perl -e 'use POSIX qw(strftime); print strftime "%Y-%m-%d",localtime(time()- 3600*96);'`
echo $DATE_YEST_FORMAT1

QUERY1=`hive -e "
set mapred.job.queue.name=hdmi-technology;
SELECT split(ckey, '\\|') AS t1
                    ,created_time
                FROM (
                    SELECT CONCAT (
                            buyer_id
                            ,'|'
                            ,item_id
                            ) AS ckey
                        ,created_time
                    FROM dw_checkout_trans
                    WHERE to_date(from_unixtime(cast(UNIX_TIMESTAMP(created_time) AS BIGINT))) = '$DATE_YEST_FORMAT1' distribute BY ckey sort BY ckey
                        ,created_time DESC
                    ) a
                WHERE rank(ckey) < 1;"`

Problem Statement:-

I am running the above shell script as-

bash -x test4.sh

If you see this line in the above hive sql query:

**SELECT split(ckey, '\\|') AS t1**.  

Do I need to escape slash sign to make it to work in shell script?

  • 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-09T14:15:17+00:00Added an answer on June 9, 2026 at 2:15 pm

    Inside backticks and double quotes, you basically need to double your backslashes, yes. If a backslash is not a known escape sequence, it will be preserved, though.

    bash$ echo "foo\bar"
    foo\bar
    
    bash$ echo "foo\\bar"
    foo\bar
    
    bash$ echo "split(ckey, '\\|')"
    split(ckey, '\|')
    

    So if you want hive to see a double backslash there, you will need to put four backslashes in the Bash script.

    See further e.g. http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_03.html

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

Sidebar

Related Questions

Below is my shell script from which I am running my Hive query. In
I'm attempting to emulate the functionality of the bash shell script below using a
I have a shell script script here as below: #!/bin/bash CPUSELECTION=1 386SX off \
My shell script is as shown below: #!/bin/bash # Make sure only root can
Below is my shell script that is working fine. #!/bin/bash DATE_YEST_FORMAT2=`perl -e 'use POSIX
I have this shell script #!/bin/sh ############################################################# # Example startup script for the SecureTrading
i have unix shell script which is need to be run like below test_sh
I need a perl/shell script which will replace all the occurences of below HTML
I have a simple shell script whose also is below: #!/usr/bin/sh echo starting the
I have class like this below shown. which contains the shopping items where the

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.