An array element, as is any variable in awk, is created on first reference as an empty entity. Empty, as does 0, represents the boolean value FALSE. So OCC[$4] on its first occurrence, is created, empty, and represents FALSE. The "!" inverts that value, so !OCC[$4] is TRUE, leading to the execution of this branch on its first occurrence. Then ++ does a post-increment on the value so it will be FALSE from then on.
Thank you. Also I have another question. Basically for the input file (calculate_contacts_HS_*.pdb.txt) I want that all lines that have ALA in first or second column sum the third column numerical values of those lines. In the input file given below it would have to be 3 lines that contain ALA in 2nd column (but it can also be in 1st) and 3rd column summed would be: 1.32859+6.90889+0.0962809=8.333761. The example of input file is this:
and the script is this:
but for this script I don't get any value. When I run the script through command the output I get is this:
Because in my script AAA is assigned to one of the 20 values (ALA, ASN, ARG, ASP, CYS, GLU, GLN, LEU, ILE, LYS, MET, etc.) therefore $AAA can be assigned to different values, but for this case let's assume that $AAA = ALA.
Hello,
Giving those commands:
cat > myfile
1
2
3
^D
cat myfile | awk '{ s=s+$1 ; print s}'
The output is:
1
3
6
It seems like this command iterates each time on a different row so $1 is the first field of each row.. But what caused it to refer to each row ?.
What I mean... (3 Replies)
So while this seemed totally trivial it turned out to be much more difficult than I had thought.
I have a file with 3 rows, and I "just" want to add each field n number of times. E.g.
> cat file.txt
0.5
-0.1
0.6
for n=3 into:
cat newfile.txt
0.5 0.5 0.5
-0.1 -0.1 -0.1
0.6 0.6 0.6
I... (4 Replies)
Hi all,
I download and install lessfs for deduplication,
I copy files in /SharedFiles directory and lessfs work right and not store again copy files,
but, when i delete all files in /SharedFiles , not return free space to total space,
files not show in /SharedFiles , but not copy new files in... (3 Replies)
Hey,
I am making a Facebook like Page system as my first project, So far it's been bate in mind I did it from my 3DS at the same time as my PC gets replaced, So far it's turned out great. Now I am on to creation the blocking system I need to get the code to say If the user already likes the... (0 Replies)
i have many questions concerning the FD.
it was stated that "to redirect Error to output std, you have to write the following code"
# ls -alt FileNotThere File > logfile 2>&1
# cat logfile
ls: cannot access FileNotThere: No such file or directory
-rw-r--r-- 1 root root 0 2010-02-26... (9 Replies)
Hi all,
Actually 2 files are there - file1, file2.
file1 contains --->
london
mosco
america
russia
mosco
file2 contains -->
europe
india
japan
mosco
england
london
Question is I want to print all the city names without duplication cities in those... (10 Replies)
I have a file, let's say 1.jpg, and I have a text file that contains a list of filenames I would like to duplicate 1.jpg as (i.e., 2.jpg, 3.jpg, 4.jpg, etc.). The filenames that I want to create are all on separate lines, one per line.
I'm sure there's a simple solution, but I'm not claiming to... (7 Replies)
Hi, I'm stuck in an awkward situation please help :)
I have two identical Seagate 80GB harddrives.
My objective is a bit strange.
1.I want to have a cloned disk as bootable backup
2.When booting using the master drive, I also want to mount the cloned backup disk so I can do incremental... (6 Replies)
I was wondering if it was possible to tell awk to print the output of a command in the print.
.... | awk '{print $0}'
I would like it to print the date right before $0, so something like (this doesn't work though)
.... | awk '{print date $0}' (4 Replies)