Sponsored Content
Top Forums Shell Programming and Scripting read line by line and calculate the co-presence of variables Post 302714771 by DGPickett on Friday 12th of October 2012 03:43:27 PM
Old 10-12-2012
Well, the SQL flavored solution is to decompose the table into a simpler table, columns into rows, with a union in a derived table, for instance:
Code:
Var Obs
A 1
A 2
A 3
B 2
C 1

Now you can join that table to itself, where a.obs=b.obs and (to avoid self and duplicate corelations, if you care) a.var < b.var

In SQL, when someone puts the cells of like entities that should be many rows into columns, a rotated array, you need unions to view the few rows many columns as one column many rows. Conversely, if you need to turn cells from many rows into columns of one row, you need to use joins. It is a common RDBMS design error to put arrays horizontally in rows when they belong vertically in one column many rows.

Now if we start talking lines and columns, 'union' is concatenate (cat, >> or just multiple passes in a subshell), 'join' is, surprise, 'sort' and 'join'; 'where' is in the join or grep. Deciding 'A' < 'B' is more a perl chr()/ord() or C question, but you were accepting self and duplicate matches above.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to read a line and put it into 3 variables

Hi All, I'll get a file whose 2nd line contains 3 fields: filename(variable length), file size char(10), and record count int(10). How do I cut it and put it into 3 variables? eg: abcd.csv01234567891111111111 now I want: $one = abcd.csv, $two = 0123456789, $three = 1111111111. I also... (8 Replies)
Discussion started by: Mandab
8 Replies

2. Shell Programming and Scripting

Read variables from line to fixed length

I would like to make a script to read three variables (no fixed length or position) from a line and write them into a file, with fixed length and right-justified in each column. The fixed text (text1-text4) prior to the thee variables and the variables themselves are originally separated by spaces... (3 Replies)
Discussion started by: SharkM
3 Replies

3. Shell Programming and Scripting

Input 2 files, calculate diffs line by line

Hi I am new to Unix and need help with the following (to you all I'm sure) simple task. I am trying to output the differences between previous snaphots of various filesystem sizes to the present sizes. I have three files (e.g.) : file 1 file 2 file 3 10 100 /var... (4 Replies)
Discussion started by: bigbuk
4 Replies

4. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

5. Shell Programming and Scripting

Read 1-line file and separate into multiple variables

I have one line files with 17 records separated by a semi-colon. I need to create a variable from each record, which I can do via a separate awk for each one, but I know there has to be a better way. Along with pulling out the variable, I need to convert some url coding like a + to a space, etc.... (4 Replies)
Discussion started by: numele
4 Replies

6. Shell Programming and Scripting

How to calculate mean in AWK? line by line several files, thousands of lines

I'm kinda stuck on this one, I have 7 files with 30.000 lines/file like this 050 0.023 0.504336 050 0.024 0.529521 050 0.025 0.538908 050 0.026 0.537035 I want to find the mean line by line of the third column from the files named like this: Stat-f-1.dat .... Stat-f-7.dat Stat-s-1.dat... (8 Replies)
Discussion started by: AriasFco
8 Replies

7. Shell Programming and Scripting

how to read the contents of two files line by line and compare the line by line?

Hi All, I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Discussion started by: mjavalkar
4 Replies

8. Shell Programming and Scripting

Need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line...

Hello, I need a program that read a file line by line and prints out lines 1, 2 & 3 after an empty line... An example of entries in the file would be: SRVXPAPI001 ERRO JUN24 07:28:34 1775 REASON= 0000, PROCID= #E506 #1065: TPCIPPR, INDEX= 003F ... (8 Replies)
Discussion started by: Ferocci
8 Replies

9. Shell Programming and Scripting

How to read file line by line and compare subset of 1st line with 2nd?

Hi all, I have a log file say Test.log that gets updated continuously and it has data in pipe separated format. A sample log file would look like: <date1>|<data1>|<url1>|<result1> <date2>|<data2>|<url2>|<result2> <date3>|<data3>|<url3>|<result3> <date4>|<data4>|<url4>|<result4> What I... (3 Replies)
Discussion started by: pat_pramod
3 Replies

10. UNIX for Beginners Questions & Answers

Read line and save fields as variables

Hej guys, I am trying to read a csv file line by line, save it's fields as variables per line so I can use them as parameters and execute stuff. I am new to shell scripting and was just strictly following a tutorial. Somehow my version seems to ignore the loop. Any help? TY! :) #!/bin/bash... (12 Replies)
Discussion started by: Splinter479
12 Replies
tpm_setpresence(8)					      System Manager's Manual						tpm_setpresence(8)

							 TPM Management - tpm_setpresence

NAME
tpm_setpresence- change TPM physical presence states or settings SYNOPSIS
tpm_setpresence [OPTION] DESCRIPTION
tpm_setpresence reports the status of the TPM's flags regarding physical presence. This is the default behavior and also accessible via the --status option. Requesting a report of this status prompts for the owner password. The --assert option changes the TPM to the physically present state. The --clear option changes the TPM to the not present state. The --lock option locks the TPM to the current physical presence state for the current boot cycle. The --enable-cmd option allows the TPM to accept local commands to toggle physical presence states. The --disable-cmd option prevents the TPM from accepting local commands to toggle physical presence states. The --enable- hw option allows the TPM to accept hardware signals to toggle physical presence states. The --disable-hw option prevents the TPM from accepting hardware signals to toggle physical presence states. The --set-lifetime-lock option locks the Command and Hardware enablement flags in their current state permenantly. This option can never be undone. The system will attempt to use the owner password to display the current states before preceding unless the --yes option is given to answer yes to all questions. All changes are made with the TSC_Physical Presence API. -h, --help Display command usage info. -v, --version Display command version info. -l, --log [none|error|info|debug] Set logging level. -u, --unicode Use TSS UNICODE encoding for passwords to comply with applications using TSS popup boxes -a, --assert Assert that an admin is physically present at the machine. -c, --clear Remove the assertion that an admin is physically present at the machine. --lock Lock the assertions of physical presence in there current states until a reboot. --enable-cmd Allow use of commands to signal an admin is physically present. --disable-cmd Disallow use of commands to signal an admin is physically present. --enable-hw Allow use of hardware signals to signal an admin is physically present. --disable-hw Disallow use of hardware signals to signal an admin is physically present. --set-lifetime-lock Allow no further changes to the flags controling how physical presence can be signaled. This is PERMANENT. -y, --yes Answer yes to all questions. Only applicable with --set-lifetime-lock. -z, --well-known Authenticate using 20 bytes of zeros as owner password (the default TSS Well Known Secret), instead of prompting for an owner password. SEE ALSO
tpm_version(1), tpm_setenable(8), tpm_setactive(8), tpm_setownable(8), tcsd(8) REPORTING BUGS
Report bugs to <trousers-users@lists.sourceforge.net> TPM Management 2005-05-06 tpm_setpresence(8)
All times are GMT -4. The time now is 05:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy