I've tried seperating lines, adding more semicolons at the ends of the line or before the curly bracket BASH-style. Nothing seems to work.
I have other ternary statements in the code that work fine like:
Mike
The ternary operator returns its decision as a value, i.e. return( (x<0)?(-x):x ). If it doesn't make sense as an expression you can't cram it in there. { } blocks don't belong there.
I think you can put a function in there.
Last edited by Corona688; 04-24-2015 at 05:54 PM..
Not sure what you mean by which syntax error? I posted the entire awk error output, there was nothing else.
OK, so I seperated it out into single expressions:
The first line works, but the second two do not.
Is there some reason it works for strings and not for numbers?
I see your edit while I was posting. I don't think your code example handles midnight correctly, which is the reason I did not try to do it on one conditional.
00:00 needs to become 12:00 AM not 00:00 AM.
I'm just as interested in understanding why it is not working than finding working code.
Mike
---------- Post updated at 02:15 PM ---------- Previous update was at 02:06 PM ----------
Trying something else:
No errors. I need to ckeck the output.
So if that is the right way to use it, why do the string lines do exactly what is expected of them?
Mike
Last edited by Michael Stora; 04-24-2015 at 06:21 PM..
Could somebody gently point out the error of my ways in the below (the flu I'm fighting might be contributing to my current haplessness)
awk -F="\t" \
'{
for (i = 1; i <= NR; i++);
FNR == i;
{
if (length($3) < 56 && length($1) > 56)
$1=($1" "$2); $2=$3; $3=$4;
... (1 Reply)
hi,
i have a bash script that i want to receive a a string from another bash file. But because the string has a dot in the middle it gives me an error. The error is in this line:
let valor=$1
and the value passed is rules.txt
the error is:
let: valor=rules.txt: syntax error: invalid... (2 Replies)
Hi guys,
I confused about syntax used in OR script as follow:
I have this sample file separated by "|" containing:
January|Month No. 1
February|Month No. 2
March|Month No. 3
April|Month No. 4
May|Month No. 5
June|Month No. 6
July|Month No. 7
August|Month No. 8
September|Month No. 9... (11 Replies)
Hi,
Can someone give me an example of how to use zsh's ternary operator?
I tried:
# a=1
# c=( a ? "true" : "false" )
and got:
zsh: no matches found: ?
I'm running zsh 4.2 on RHEL AS 4.
Thanks!
Paul (1 Reply)
Hi All,
can some one figure out the syntax issue here. How to overcome this?
#!/bin/sh
$ HFR_MAIL=NO
$ PRP_MAIL=NO
$ MC_MAIL=NO
$ if && && ]; then
> echo "NO "
> else
> echo "YES"
> fi
test: unknown operator NO
$ if && && ]; then
> echo "NO"
> else
> echo "YES"
>... (4 Replies)
When i tyr this, it gives me a syntax error...i tried removing quotes,removing spaces,replacing -eq with '='.. Can somebody suggest that is the problem?
if ]; then (4 Replies)
hi there
i write one awk script file in shell programing
the code is related to dd/mm/yy to month, day year format
but i get an error
please can anybody help me out in this problem ??????
i give my code here including error
awk `
# date-month -- convert mm/dd/yy to month day,... (2 Replies)
Due to some syntax error, my below code is not working.
#!/usr/bin/ksh
nawk '
BEGIN {
cur_val=0; cur_zero=0; cur_nine=0;
sum_zero=0; sum_nine=0;
}
/^/ {
cur_val=substr($0,5,2);
if("cur_val" == "0")
{
... (3 Replies)
How do I interpret the following ternary operation?
fn_max(var_type a,var_type b,var_type c)
{
var_type t;
return(t=((t>a?:t;a)>b)?:t;b)>c?:t;c)
}
Thanks (1 Reply)