LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-16-2014, 12:53 AM   #1
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Rep: Reputation: Disabled
getting syntax error


Hi,

here is the piece of code where i am getting error:
Code:
for i in DCP KIVR CCCD
do
        ${i}_A=`grep "2014-07-14 06" $DATA_DIR/${i}_hourly_paya.txt|awk -F '|' '{printf "%-10d\n",$2}'`



	if [[ ! -n "${${i}_A}" ]]
	then
        echo 2014-07-14 06 0 >> $DATA_DIR/${i}_hourly_paya_TMP.txt
        else
        echo 2014-07-14 06 ${${i}_A} >> $DATA_DIR/${i}_hourly_paya_TMP.txt
        fi
done
output:

$ ./san_tst.sh
./san_tst.sh: line 4: syntax error at line 12: `!' unexpected

could someone please help?

Last edited by santosh0782; 07-16-2014 at 12:54 AM.
 
Old 07-16-2014, 01:10 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,

why are you trying to use such a convoluted identifier for your local variable. Can you not do something like:
Code:
for i in DCP KIVR CCCD
do
        a=`grep "2014-07-14 06" $DATA_DIR/${i}_hourly_paya.txt|awk -F '|' '{printf "%-10d\n",$2}'`



	if [[ ! -n "$a" ]]
	then
        echo 2014-07-14 06 0 >> $DATA_DIR/${i}_hourly_paya_TMP.txt
        else
        echo 2014-07-14 06 $a >> $DATA_DIR/${i}_hourly_paya_TMP.txt
        fi
done
There may be other issues but that's what jumped out first.
 
1 members found this post helpful.
Old 07-16-2014, 01:37 AM   #3
santosh0782
Member
 
Registered: Nov 2013
Posts: 132

Original Poster
Rep: Reputation: Disabled
Thanks a lot :-). tried above provided,It is working fine now.. :-)
 
  


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
rsync error: syntax or usage error (code 1) at main.c(1490) [receiver=3.0.6] boby.kumar Linux - Newbie 4 11-22-2013 05:58 AM
having trouble with php code giving a Parse error: syntax error, unexpected '>' ashevillan Programming 6 03-14-2013 11:37 AM
script.pl with sed shell calls: sh error syntax error near unexpected token `(' MMaddoxx Programming 7 11-24-2011 09:00 AM
[python] syntax Error : invalid syntax Python_user Programming 2 09-06-2009 01:52 PM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 07:09 PM


All times are GMT -5. The time now is 03: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