Sponsored Content
Full Discussion: awk using ssh variable?
Top Forums Shell Programming and Scripting awk using ssh variable? Post 302221146 by RisingSun on Sunday 3rd of August 2008 04:34:51 PM
Old 08-03-2008
awk using ssh variable?

I have a file named Atoms that has a list of atoms listed vertically, like:

O
C
Na

etc. There is a variable number of them.

I want to count their occurences in another file. I want to do this by saving each atom as a variable, preferabbly in an associative array, then counting how many there are in the other file. I already can count the number of atoms, and I save that into $numatoms

My problem right now is the awk command recognizing the variable $i from the for loop. The part where it says NR=="$i" doesn't seem to work. Also, afterward, I still wouldn't know how to count the occurences in another file, which is also based on a variable, titled $name.axyz. I'm fairly new, and help would be appreciated!!! Thanks.


for (( i=1; i < $numatoms; i++ )); do
count[$i]=$(awk {'NR=='"$i"'{ print "$1"}' Atoms)
echo $count[$i]
done
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue in Variable in SSH

Friends, I want to write a script. The logic follows 1. Script starts 2. SSH to Remote Machine and check whether /home/testUser dir is there or not. 3. If it is there, am assigning a value to a variable. else not 4. If the variable is set, the do the copy from remote machine to my local... (2 Replies)
Discussion started by: balamv
2 Replies

2. Shell Programming and Scripting

setting a variable, using SSH and awk?

hi there I am trying to get a value from a remote machine into a local variable. To get this value i want to use awk but im having trouble getting it to run, am i escaping in the right places here and using the right quotes (i must have tried a million combinations :() # VAR=`ssh server1... (5 Replies)
Discussion started by: hcclnoodles
5 Replies

3. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

4. Shell Programming and Scripting

Variable value in ssh

Hi, I'm creating a script where I connet to a remote machine, I execute a command (I get a pid of an application) and I kill the application. I wrote this: ssh $HOST_WHITEBOARD<<END COMMAND_GET_PID_WHITE="ps aux | grep something | awk '/Sl+/ {print \$2}' | awk 'begin {row=0} row==0... (4 Replies)
Discussion started by: abdujaparov
4 Replies

5. Shell Programming and Scripting

use awk to ssh from variable in flat file

flat file looks like ooss-pfgg-1234,vol_name_1, mail-list decoded = hostname,volum_name,mail_list each line has diff info am trying to ssh into each fist field, check vol usage for second field, and if greater than 90% send mail to mail-list got the second and third part working, ... (1 Reply)
Discussion started by: riegersteve
1 Replies

6. Shell Programming and Scripting

using awk for setting variable but change the output of this variable within awk

Hi all, Hope someone can help me out here. I have this BASH script (see below) My problem lies with the variable path. The output of the command find will give me several fields. The 9th field is the path. I want to captured that and the I want to filter this to a specific level. The... (6 Replies)
Discussion started by: Cowardly
6 Replies

7. Shell Programming and Scripting

help about the ssh accpect a variable

# dir=/mnt # ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@10.0.2.3 'cd $dir;ls' The $dir doesn't take effect any help?? ( I want use variable to do something Thanks in advance (1 Reply)
Discussion started by: yanglei_fage
1 Replies

8. Shell Programming and Scripting

how to assign value to the variable through ssh

Hi All, i am writing a shellscript to compare cksum of the file in local machine and after copying to remote machine. i am not able to assign command output value to variable in remote machine through SSH. PFB code for this. code: ###### Get File size of the file in local remote system ... (3 Replies)
Discussion started by: katamsivakumar
3 Replies

9. Shell Programming and Scripting

Passing a variable via ssh, can't quite get it right

Hi Guys n Girls, Below im using a while command to wait for a file on another server then carrying on with the script..... I dont believe the $Sausage1 variable is being passed to the other server so its not finding the file. If i replace the variable with the date then it works as expected. ... (2 Replies)
Discussion started by: twinion
2 Replies

10. UNIX for Beginners Questions & Answers

How can I assign awk's variable to shell script's variable?

I have the following script, and I want to assign the output ($10 and $5) from awk to N and L: grdinfo data.grd | awk '{print $10,$5}'| read N L output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies
XInternAtom(3)							  XLIB FUNCTIONS						    XInternAtom(3)

NAME
XInternAtom, XInternAtoms, XGetAtomName, XGetAtomNames - create or return atom names SYNTAX
Atom XInternAtom(Display *display, char *atom_name, Bool only_if_exists); Status XInternAtoms(Display *display, char **names, int count, Bool only_if_exists, Atom *atoms_return); char *XGetAtomName(Display *display, Atom atom); Status XGetAtomNames(Display *display, Atom *atoms, int count, char **names_return); ARGUMENTS
atom Specifies the atom for the property name you want returned. atoms Specifies the array of atoms. atom_name Specifies the name associated with the atom you want returned. atoms_return Returns the atoms. count Specifies the number of atom names in the array. count Specifies the number of atoms in the array. display Specifies the connection to the X server. names Specifies the array of atom names. names_return Returns the atom names. only_if_exists Specifies a Boolean value that indicates whether the atom must be created. DESCRIPTION
The XInternAtom function returns the atom identifier associated with the specified atom_name string. If only_if_exists is False, the atom is created if it does not exist. Therefore, XInternAtom can return None. If the atom name is not in the Host Portable Character Encoding, the result is implementation-dependent. Uppercase and lowercase matter; the strings ``thing'', ``Thing'', and ``thinG'' all designate dif- ferent atoms. The atom will remain defined even after the client's connection closes. It will become undefined only when the last connec- tion to the X server closes. XInternAtom can generate BadAlloc and BadValue errors. The XInternAtoms function returns the atom identifiers associated with the specified names. The atoms are stored in the atoms_return array supplied by the caller. Calling this function is equivalent to calling XInternAtom for each of the names in turn with the specified value of only_if_exists, but this function minimizes the number of round-trip protocol exchanges between the client and the X server. This function returns a nonzero status if atoms are returned for all of the names; otherwise, it returns zero. XInternAtoms can generate BadAlloc and BadValue errors. The XGetAtomName function returns the name associated with the specified atom. If the data returned by the server is in the Latin Portable Character Encoding, then the returned string is in the Host Portable Character Encoding. Otherwise, the result is implementation-depen- dent. To free the resulting string, call XFree. XGetAtomName can generate a BadAtom error. The XGetAtomNames function returns the names associated with the specified atoms. The names are stored in the names_return array supplied by the caller. Calling this function is equivalent to calling XGetAtomName for each of the atoms in turn, but this function minimizes the number of round-trip protocol exchanges between the client and the X server. This function returns a nonzero status if names are returned for all of the atoms; otherwise, it returns zero. XGetAtomNames can generate a BadAtom error. DIAGNOSTICS
BadAlloc The server failed to allocate the requested resource or server memory. BadAtom A value for an Atom argument does not name a defined Atom. BadValue Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argu- ment, the full range defined by the argument's type is accepted. Any argument defined as a set of alternatives can generate this error. SEE ALSO
XFree(3), XGetWindowProperty(3) Xlib - C Language X Interface X Version 11 libX11 1.6.0 XInternAtom(3)
All times are GMT -4. The time now is 05:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy