PRINT TWO VARIABLES IN ONE LINE


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PRINT TWO VARIABLES IN ONE LINE
# 1  
Old 07-16-2012
PRINT TWO VARIABLES IN ONE LINE

my command
Code:
nawk -F' ' '{for(i=1;i<=NF;i++){if ($i ~ /XX/) print i}}' TOM.bk

The output is in two lines as below
Code:
12
30

i want the output in one line with comma delimited
as below
Code:
12,30

the 23 and 79 are column numbers in one line of the file.
so i want all the two columns generated per line listed as below:
final output should look like
Code:
12,30
15,25
34,67

# 2  
Old 07-16-2012
Original thread here.

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Compare two variables and print the difference

compare two variables and print the difference i have two variables X1=rac1,rac2 Y1=rac2,rac3 output=rac1,rac3 Use code tags to wrap code fragments or data samples. (1 Reply)
Discussion started by: jhonnyrip
1 Replies

2. Shell Programming and Scripting

Compare two variables and print the difference

Hi PRIM_SEQ=`some sql code` and output of PRIM_SEQ is like below 120 130 STB_SEQ=`some sql code` and output of STB_SEQ is like below 115 110 i need to compare this two variables output ( decimal numbers) 1) What I want to do is to compare every number in the PRIM_SEQ with... (8 Replies)
Discussion started by: amar1208
8 Replies

3. Shell Programming and Scripting

Print whole line if variables matches

Der colleagues, 4 days I am trying to solve my issue and no success.. Maybe you can give me a clue how to achieve what I need.. So I have two files. file1 example: 1_column1.1 1_column2.1 aaa 1_column4.1 1_column1.2 1_column2.2 ttt 1_column4.2 1_column1.3 1_column2.3 ... (10 Replies)
Discussion started by: nypreH
10 Replies

4. Shell Programming and Scripting

read line by line and calculate the co-presence of variables

Hey guyz, I have a table which shows the presence or absence of my variables (A,B,C,...) in my observations (1,2,3,...) * A B C ... 1 1 0 1 2 1 1 0 3 1 0 0 ... I want to calculate the co-presence of my variables. to have a table shows the pairwise presence of the variables (have... (1 Reply)
Discussion started by: @man
1 Replies

5. UNIX for Dummies Questions & Answers

Print Positional variables

Hi, I have to use the vaious kind of filters based on various fields in the input file like - count occurence of cases where "TRK-GRP" = 169 or like "ADDR-DIG" = 80080. I don;t know the positional variable for all below fields. Please help. Input File : +++ BEST 12-05-27 15:06:49 MDI 3478... (2 Replies)
Discussion started by: vanand420
2 Replies

6. Shell Programming and Scripting

To print variables using awk

Can anyone help me with how to print the variable using a awk statement. for i in ` cat serverlist.txt ` ; do my command | awk '{print $1 $2 $i}' done It should print like below but it is not XXXXX YYYYY Servername XXXXX YYYYY Servername XXXXX YYYYY Servername XXXXX YYYYY... (6 Replies)
Discussion started by: rrb2009
6 Replies

7. Shell Programming and Scripting

linux shell script to take variables from two different files line by line

Friends I need to have a shell script which will feed variables from two different files line-by-line. For example, I have two files - permission and file_name. Contents of permission is - 644 755 .... contents of file_name /file1 /file2 ..... Now I want 644 permission will be... (4 Replies)
Discussion started by: atanubanerji
4 Replies

8. Shell Programming and Scripting

For Loop And Print 2 Variables

I have the following loop: for I in `ldm ls |grep -v ^NAME| awk '{print $1}'` do ldm ls -o network $I | echo $I | tr -s ' ' | cut -f6 -d " " | more +9 I would like the following displayed to a file: The value of $I, followed by a newline, then the information from the rest of the... (3 Replies)
Discussion started by: hxman
3 Replies

9. Shell Programming and Scripting

How can I print variables im using in makefiles?

for example in my make file im building path from env variables and string but need to see what is did what is the best way to print the result? say I have in my Makefile : exec_prefix = $(RUN_ENV_LOCAL)/apache and I will like to print the exec_prefix value , how can it be done ? (1 Reply)
Discussion started by: umen
1 Replies

10. Shell Programming and Scripting

cannot print 3 variables on same line

Hi, I have a file containing emails about some issues. Using a bourne shell script, I need to extract the issue number from the URL's contained in the file (all URL's look like this : http://www.openoffice.org/issues/show_bug.cgi?id=1881) and then print out the issue number, status and... (2 Replies)
Discussion started by: Chris Jones
2 Replies
Login or Register to Ask a Question