LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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-15-2014, 11:53 PM   #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-15-2014 at 11:54 PM.
 
Old 07-16-2014, 12:10 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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, 12: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



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 04:58 AM
having trouble with php code giving a Parse error: syntax error, unexpected '>' ashevillan Programming 6 03-14-2013 10:37 AM
script.pl with sed shell calls: sh error syntax error near unexpected token `(' MMaddoxx Programming 7 11-24-2011 08:00 AM
[python] syntax Error : invalid syntax Python_user Programming 2 09-06-2009 12:52 PM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 06:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:01 PM.

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
Open Source Consulting | Domain Registration