I am working on a code with my adviser,but have run into some problems. I was wondering: Can anyone see what I am doing wrong and/or point me in the right direction. I have an experiment where objects are presented in a circular display, and rotate clockwise or counter depending on the trial. The output produced by the awk file below is erroneous. I appreciate any help on this issue.
To debug your (messy) code, put the print statements throughout the script. You'd see immediately, that variable "pos" is always empty.
You try to set the 'pos' var here:
But the fourth field is not this, it is an integer before:
Furthermore, the pair (197, 383) has a space inbetween, so it's actually two fields. But wait, the FS is set to tab character, so you actually have only one filed ($1) in each line, since there are no tabs there. You could take out the FS="\t" line, and test for $5 $6:
but honestly, that code has so many errors, i suggest you rewrite it. Try to use 'case' statements, they are much more easier to read and less prone than nested if statements.
And I would take out the space from the paired values (511, 69) change to (511,69) so that the input is properly delimited, at least.
Good luck.
This code works on the above file:
However, when I wanted to change it up a little bit, for another experiment, and have the target appear in only four positions I run into more errors.
I have a file that looks like this:
RECORDING_SESSION_LABEL TRIAL_START_TIME TRIAL_FIXATION_TOTAL CURRENT_FIX_INDEX CURRENT_FIX_X CURRENT_FIX_Y CURRENT_FIX_START CURRENT_FIX_END identifier trialtype cueimage preimage staticimage rotatedimage targetloc targetroc rot 1092166997352530.8366.8230836101stimN181cue.jpgstimN181pre.jpgstimN181sta.jpgstimN181-of1.jpgright-718,303-11092166997353688.3367.18791077101stimN181cue.jpgstimN181pre.jpgstimN181sta.jpgstimN181-of1.jpgright(718, 303)-11092166997354561.1356.611061323101stimN181cue.jpgstimN181pre.jpgstimN181sta.jpgstimN181-of1.jpgright(718, 303)-11092166997355687.9297.913661596101stimN181cue.jpgstimN181pre.jpgstimN181sta.jpgstimN181-of1.jpgright(718, 303)-11092158626431508.3391.27235110stimN191cue.jpgstimN191pre.jpgstimN191sta.jpgstimN191-of1.jpgright(718, 303)-11092158626432360.1375.7276711110stimN191cue.jpgstimN191pre.jpgstimN191sta.jpgstimN191-of1.jpgright(718, 303)-11092158626433693.8378765813110stimN191cue.jpgstimN191pre.jpgstimN191sta.jpgstimN191-of1.jpgright(718, 303)-11092158843631516.8367.67746120stimN201cue.jpgstimN201pre.jpgstimN201sta.jpgstimN201-of1.jpgright(718, 303)-11092158843632649.6372.5774909120stimN201cue.jpgstimN201pre.jpgstimN201sta.jpgstimN201-of1.jpgright(718, 303)-11092158843633700.9365.29301110120stimN201cue.jpgstimN201pre.jpgstimN201sta.jpgstimN201-of1.jpgright(718, 303)-11092157832251510.3374.87271131stimN211cue.jpgstimN211pre.jpgstimN211sta.jpgstimN211-of1.jpgright(718, 303)-11092157832252531.3373.3280751131stimN211cue.jpgstimN211pre.jpgstimN211sta.jpgstimN211-of1.jpgright(718, 303)-11092157832253675.2372.57821040131stimN211cue.jpgstimN211pre.jpgstimN211sta.jpgstimN211-of1.jpgright(718, 303)-11092157832254707.334910581169131stimN211cue.jpgstimN211pre.jpgstimN211sta.jpgstimN211-of1.jpgright(718, 303)-1109215783225572029411941431131stimN211cue.jpgstimN211pre.jpgstimN211sta.jpgstimN211-of1.jpgright(718, 303)-11092170561551516.63847213141stimN21cue.jpgstimN21pre.jpgstimN21sta.jpgstimN21-of1.jpgright(718, 303)-11092170561552529374223752141stimN21cue.jpgstimN21pre.jpgstimN21sta.jpgstimN21-of1.jpgright(718, 303)-11092170561553699.6361.67941045141stimN21cue.jpgstimN21pre.jpgstimN21sta.jpgstimN21-of1.jpgright(718, 303)-11092170561554701.932910631224141stimN21cue.jpgstimN21pre.jpgstimN21sta.jpgstimN21-of1.jpgright(718, 303)-11092170561555715.428012451293141stimN21cue.jpgstimN21pre.jpgstimN21sta.jpgstimN21-of1.jpgright(718, 303)-11092176406941516.8370.27211150stimN221cue.jpgstimN221pre.jpgstimN221sta.jpgstimN221-of1.jpgright(718, 303)-11092176406942532.1370219708150stimN221cue.jpgstimN221pre.jpgstimN221sta.jpgstimN221-of1.jpgright(718, 303)-11092176406943658.1365.5750897150stimN221cue.jpgstimN221pre.jpgstimN221sta.jpgstimN221-of1.jpgright(718, 303)-11092176406944711.53639181152150stimN221cue.jpgstimN221pre.jpgstimN221sta.jpgstimN221-of1.jpgright(718, 303)-11092162016551506.7376.67270161stimN231cue.jpgstimN231pre.jpgstimN231sta.jpgstimN231-of1.jpgright(718, 303)-11092162016552520.5371.2278709161stimN231cue.jpgstimN231pre.jpgstimN231sta.jpgstimN231-of1.jpgright(718, 303)-11092162016553669363.2746927161stimN231cue.jpgstimN231pre.jpgstimN231sta.jpgstimN231-of1.jpgright(718, 303)-11092162016554701.2421.89521016161stimN231cue.jpgstimN231pre.jpgstimN231sta.jpgstimN231-of1.jpgright(718, 303)-11092162016555707338.610491183161stimN231cue.jpgstimN231pre.jpgstimN231sta.jpgstimN231-of1.jpgright(718, 303)-11092170335241523.1393.37222170stimN241cue.jpgstimN241pre.jpgstimN241sta.jpgstimN241-of1.jpgright(718, 303)-11092170335242523.2386.7230404170stimN241cue.jpgstimN241pre.jpgstimN241sta.jpgstimN241-of1.jpgright(718, 303)-11092170335243373.9359.2442691170stimN241cue.jpgstimN241pre.jpgstimN241sta.jpgstimN241-of1.jpgright(718, 303)-11092170335244674.2361.3733819170stimN241cue.jpgstimN241pre.jpgstimN241sta.jpgstimN241-of1.jpgright(718, 303)-11092161482931521.63717881180stimN251cue.jpgstimN251pre.jpgstimN251sta.jpgstimN251-of1.jpgright(718, 303)-11092161482932642.1368.19171050180stimN251cue.jpgstimN251pre.jpgstimN251sta.jpgstimN251-of1.jpgright(718, 303)-11092161482933687.3369.210711263180stimN251cue.jpgstimN251pre.jpgstimN251sta.jpgstimN251-of1.jpgright(718, 303)-11092168294121522.4374.57843190stimN261cue.jpgstimN261pre.jpgstimN261sta.jpgstimN261-of1.jpgright(718, 303)-11092168294122697.9369.78821075190stimN261cue.jpgstimN261pre.jpgstimN261sta.jpgstimN261-of1.jpgright(718, 303)-11092163358051524.3372.27766201stimN271cue.jpgstimN271pre.jpgstimN271sta.jpgstimN271-of1.jpgright(718, 303)-11092163358052672.1371.7797991201stimN271cue.jpgstimN271pre.jpgstimN271sta.jpgstimN271-of1.jpgright(718, 303)-11092163358053701.9413.310121049201stimN271cue.jpgstimN271pre.jpgstimN271sta.jpgstimN271-of1.jpgright(718, 303)-11092163358054702.1336.710741243201stimN271cue.jpgstimN271pre.jpgstimN271sta.jpgstimN271-of1.jpgright(718, 303)-11092163358055719292.312631316201stimN271cue.jpgstimN271pre.jpgstimN271sta.jpgstimN271-of1.jpgright(718, 303)-11092173277841526.13777865211stimN281cue.jpgstimN281pre.jpgstimN281sta.jpgstimN281-of1.jpgright(718, 303)-11092173277842683.5370.29071090211stimN281cue.jpgstimN281pre.jpgstimN281sta.jpgstimN281-of1.jpgright(718, 303)-11092173277843707.9422.911151242211stimN281cue.jpgstimN281pre.jpgstimN281sta.jpgstimN281-of1.jpgright(718, 303)-11092173277844709.5289.212791343211stimN281cue.jpgstimN281pre.jpgstimN281sta.jpgstimN281-of1.jpgright(718, 303)-110921506395121506.7408.17295221stimN31cue.jpgstimN31pre.jpgstimN31sta.jpgstimN31-of1.jpgright(718, 303)-110921506395122519.7408.8302851221stimN31cue.jpgstimN31pre.jpgstimN31sta.jpgstimN31-of1.jpgright(718, 303)-110921506395123703.5408.29261128221stimN31cue.jpgstimN31pre.jpgstimN31sta.jpgstimN31-of1.jpgright(718, 303)-110921506395124696.3356.311511271221stimN31cue.jpgstimN31pre.jpgstimN31sta.jpgstimN31-of1.jpgright(718, 303)-1
I changed the code up a bit, it follows the same logic as the above code, but instead of printing trial numbers I want the code to print accurary, error, and the identifier field. I get some syntax errors.
xxxx=xxxx+1;
if(xxxx>5){
# if(subj!=$1){ print "END\n" >>subj;}
}
subj=$1;
if ($16 == "(718, 303)"){pos=3;}
if ($16 == "(715, 447)"){pos=5;} # target can only appear in one of four places as indicated
if ($16 == "(338, 452)"){pos=11;}
if ($16 == "(339, 300)"){pos=13;}
## Generate point sets (The remainder works well when adding but not subtracting.)
## Positions start at 0 and increase as you move counter clockwise around the circle.
## So, on counter-clockwise rotation trials, the distractor will be 2 positions lower than
## the final target position. The following is a reference:
##
## No Rotatio Counter-Clockwise Rotation Clockwise Rotation
## 0 15-0-1 1-2-3 15-14-13 1-0-15
## 14 2 13-14-15 3-4-5 13-12-11 3-2-1
## 12 4
## 10 6 11-12-13 5-6-7 11-10-9 5-4-3
## 8 9-10-11 7-8-9 9-8-7 7-6-5
##
It may run without errors, but it doesn't do anything useful -- it doesn't print anything. The FS is set to "\t" but there are no tabs in the sample input you posted.
Quote:
I get some syntax errors.
Like what? Can you please post the errors you are getting? What system are you on? Which awk are you using? What is your desired output?
Quote:
Any suggestions?
You should take the time to post the exact input and desired output, using CODE tags, and be more specific about your problems, to increase your chances of getting help. Just posting a bunch of code is not enough.
I'm trying to create a shell script that takes a awk script that I wrote and a filename as an argument. I was able to get that done but I'm having trouble figuring out how to keep the header of the output at the top but sort the rest of the rows alphabetically. This is what I have now but it is... (1 Reply)
Hi
I have a text file (Input.txt) with two column entries separated by tab as given below:
aaa str1
bbb str2
cccccc str3
dddd str4
eee str3
ssss str2
sdf str3
hhh str1
fff str2
ccc str3
.....
.....
..... (1 Reply)
I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist.
diff=$1$2.diff
id=$2 new=new_$diff
echo "My id is $1"
echo "I want to sync for user account $id"
##awk command I am using is as below
cat $diff |... (1 Reply)
Discussion started by: Sarita Behera
1 Replies
4. Post Here to Contact Site Administrators and Moderators
Variable I have in my shell script
diff=$1$2.diff
id=$2
new=new_$diff
echo "My id is $1"
echo "I want to sync for user account $id"
##awk command I am using is as below
cat $diff | awk -F'~' ''$2 == "$id"' {print $0}' > $new
I could see value of $id is not passing to the awk... (0 Replies)
I am getting the following error while passing parameter to a shell script called within awk script. Any idea what's causing this issue and how to ix it ? Thanks
sh: -c: line 0: syntax error near unexpected token `newline'
sh: -c: line 0: `./billdatecalc.sh ... (10 Replies)
This is the final first release of the dynamic menu generator for pekwm (WM).
#!/bin/bash
function param_val {
awk "/^${1}=/{gsub(/^${1}="'/,""); print; exit}' $2
}
echo "Dynamic {"
for CF in `ls -c1 /usr/share/applications/*.desktop`
do
name=$(param_val Name $CF)
... (3 Replies)
hi everyone
i am trying to do this
bash> cat abc.sh
deepak()
{
echo Deepak
}
deepak
bash>./abc.sh
Deepak
so it is giving me write simply i created a func and it worked
now i modified it like this way
bash> cat abc.sh (2 Replies)
Hello,
I have this awk script that I want to execute by passing parameters through a shell script.
I'm a little confused. This awk script removes duplicates from an input file.
Ok, so I have a .sh file called rem_dups.sh
#!/usr/bin/sh... (4 Replies)
Hi guys
I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file.
#!/bin/sh
echo " $2 $3 $4 $5 $6 $7
isql -w400 -U$2 -S$5 -P$3 << xxx
use $4
go
print"**Changes to the table... (0 Replies)