Define multiple expression to single array?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Define multiple expression to single array?
# 1  
Old 03-12-2010
Define multiple expression to single array?

This is fine and working
Code:
a [1] = "A/A"

How to define some thing like this ???
Code:
a [1] = "A/A" or "T/T or some thing else

# 2  
Old 03-12-2010
I couldn't understand fully what you're expecting.

Are you expecting like this?

Code:
a[1]="A/A" || "B/B" || "C/C"


Last edited by vivekraj; 03-12-2010 at 02:48 AM..
# 3  
Old 03-12-2010
Here is my example

Code:
awk '
BEGIN {
  a[1] = "\"A/A\""
  a[2] = "\"A/G\""
  a[3] = "\"G/G\""
  OFS = "\t"
}
NR == FNR {
  if (NR == 1) {
    for (i = 2; i <= NF; ++i)
      s[i] = $i
    next
  }
  for (i = 2; i <= NF; ++i)
    ++b[s[i], $i]
  next
}
{
  $6 = $3
  if (FNR == 1) {
    $3 = "\"StYPE\""
    $4 = "\"Ntype\""
    $5 = "\"Stype_No\""
  } else {
    if ($1 == last) ++i
    else { last = $1; i = 1 }
    if (i in a) {
      $3 = a[i]
      $4 = i
      $5 = b[$1, a[i]]
    } else {
      $3 = "\"NULL\""
      $5 = $4 = "\"null\""
    }
  }
}
1
' input1.csv input2.csv

Take a look at bold letters
I want to define them as
Code:
  a[1] = "\"A/A\"" || "\"T/T\""|| or something else

but they are not working
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using a script to define variables and run multiple other scripts in succession.

I'm pretty new to scripting in Korn shell so please forgive me... What I'm trying to do is to create a script that calls multiple other ksh scripts and defines variables for text files. I need it to define my user defined variables (file paths, date & time stamps, etc that are currently in... (1 Reply)
Discussion started by: bluejwxn8
1 Replies

2. Shell Programming and Scripting

Print array into a single file - AWK

Hi all, I been looking for a solution to the fact that when I use: for (i=1; i<=NF; i++) print $ifields that are originally in a single line are printed in a single line I have severals files for which the first 7 are the same, but the number of variables after that can vary, for example NF... (5 Replies)
Discussion started by: PaulaL
5 Replies

3. Shell Programming and Scripting

Awk match multiple columns in multiple lines in single file

Hi, Input 7488 7389 chr1.fa chr1.fa 3546 9887 chr5.fa chr9.fa 7387 7898 chrX.fa chr3.fa 7488 7389 chr21.fa chr3.fa 7488 7389 chr1.fa chr1.fa 3546 9887 chr9.fa chr5.fa 7898 7387 chrX.fa chr3.fa Desired Output 7488 7389 chr1.fa chr1.fa 2 3546 9887 chr5.fa chr9.fa 2... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

4. Shell Programming and Scripting

Multiple lines in a single column to be merged as a single line for a record

Hi, I have a requirement with, No~Dt~Notes 1~2011/08/1~"aaa bbb ccc ddd eee fff ggg hhh" Single column alone got splitted into multiple lines. I require the output as No~Dt~Notes 1~2011/08/1~"aaa<>bbb<>ccc<>ddd<>eee<>fff<>ggg<>hhh" mean to say those new lines to be... (1 Reply)
Discussion started by: Bhuvaneswari
1 Replies

5. Shell Programming and Scripting

Matching single quote in a regular expression

I trying to match the begining of the following line in a perl script with a regular expression. $ENV{'ORACLE_HOME'} I tried this regluar expession: /\$ENV\{\'ORACLE_HOME\'\}/ Instead of match, I got a blank prompt > It seems to be a problem with the single quote. If I take it... (11 Replies)
Discussion started by: JC9672
11 Replies

6. UNIX for Dummies Questions & Answers

Grep multiple strings in multiple files using single command

Hi, I will use below command for grep single string ("osuser" is search string) ex: find . -type f | xarg grep -il osuser but i have one more string "v$session" here i want to grep in which file these two strings are present. any help is appreciated, Thanks in advance. Gagan (2 Replies)
Discussion started by: gagan4599
2 Replies

7. Shell Programming and Scripting

BASH: print matrix from single array

I am creating a report in groff and need to format data from a file into a table cell. Sample data: dador,173323,bpt,jsp,39030013338878,1 dador,173323,brew,jsp,39030013338860,1 dador,173323,brew,jsp,39030013339447,1 dador,173323,brew,jsp,39030013339538,1 I would like to build a table... (12 Replies)
Discussion started by: Bubnoff
12 Replies

8. Shell Programming and Scripting

Define multiple mail recipents in a variable in perl

hi I have a perl script from which I call a shell script and pass mail variable to it. The mail works fine if I give 1 recipient but fails for multiple. conv.pl:- $mialing = "anu\@abc.com" rest.sh $mialing rest.sh mail -s "hi" $1 This works fine But I need to define multiple... (2 Replies)
Discussion started by: infyanurag
2 Replies

9. Shell Programming and Scripting

saving values from awk expression into shell array

hi i am trying to save the values i extract from a file with the help of awk in a bash shell array. i have: exec 10<file2 while read LINE <&10; do ARRAY1=$(awk '{print $1}' file2) ((count++)) done echo ${ARRAY1} it prints just blank lines. file1 has two columns and i... (4 Replies)
Discussion started by: npatwardhan
4 Replies

10. Shell Programming and Scripting

How to define array in Bourne shell , csh & ksh

Dear friends... Kindly if any one can help me to know the differences in definning & retreiving data from arrays in the sh,csh & ksh. I always facing problems in this issue. thanks...:) BR (3 Replies)
Discussion started by: ahmad.diab
3 Replies
Login or Register to Ask a Question