Need Help in arranging the output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Help in arranging the output
# 1  
Old 10-23-2012
Need Help in arranging the output

Hello All,

Please find attached input and output files. I want to write a shell script to achieve this. I tried using awk but not getting how to do this as I am new to shell programming.

Thanks
# 2  
Old 10-23-2012
Try:
Code:
awk -vRS= '{a[$1]=a[$1](a[$1]?",":"")$2}END{for (i in a) print i","a[i]}' file

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 10-25-2012
when I am running the command that you have given me, it is throwing some errors :-

awk: syntax error near line 1
awk: illegal statement near line 1
# 4  
Old 10-25-2012
Use /usr/xpg4/bin/awk or nawk on Solaris.
# 5  
Old 10-25-2012
As I specified in the output file attached, I need an output like this -

sudeep,kapil,ritesh
...

and I am getting the output like this -

,
kapil,
ritesh,
sudeep,

Please tell me how should I modify the command....and if you don't mind, please explain the command once as I am new to scripting.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Arranging the command output into an html table format

Hi, I need to format a command output for the beolow command: runmqckm -cert -list -db $MQ_KDB -pw $PASSWD -expiry $EXP | grep -v "Certificates in database" The output will be: "ABC - cert name" From: Tuesday, May 25, 1999 11:09:40 AM CDT To: Saturday, May 25, 2019 11:39:40 AM CDT ... (3 Replies)
Discussion started by: bdpl
3 Replies

2. UNIX for Beginners Questions & Answers

Help arranging text

By using this code how can we get the stars in inverted positions? str="*" for i in 1 2 3 4 5 do echo "$str" str="$str *" done The output should be like this * * * * * * * * * * * * * * * Please use CODE tags as required by forum rules!... (5 Replies)
Discussion started by: Meeran Rizvi
5 Replies

3. Shell Programming and Scripting

Arranging output for 2 commands

I am trying to run 2 sets of commands but want their output in a particular format. The 2 commands are : md5sum $WAR_DIR/$war and java -jar $WAR_DIR/$war | grep build.release.version | awk '{print $3}' The first command gives an output of 5f5261a33b92a36f80218cf14e8271ad ... (4 Replies)
Discussion started by: Junaid Subhani
4 Replies

4. Shell Programming and Scripting

Arranging the output of a shell script into tables

Hi guys. I am new to this forum so cheers :) I have a question. I have created a shell script that puts all the output into 1 file. The out put is like this: -----IP------ Data Data Data -----IP------ Data Data Data How can i arrange this to be like this: IP | Data |... (3 Replies)
Discussion started by: Pandera
3 Replies

5. Shell Programming and Scripting

Need help in arranging data

I have a file with user activity and need to display only the start and end timestamp of the activity. I don't know how can we write an logic for this please help me in a bettr way to work on it User Activity_log ----------------------------------- ... (5 Replies)
Discussion started by: lazydev
5 Replies

6. Shell Programming and Scripting

Arranging Haphazard output in readable format

Dear Friends, Need your help once again. I have a sql to download output in pipe separated format. Due to that output looks haphazard. E.G. $cat output.temp 123|456|789|0 67345123||3455|1 7124563|432343414||345324 By any was can we arrange it in tabular format for better... (4 Replies)
Discussion started by: anushree.a
4 Replies

7. UNIX for Dummies Questions & Answers

Arranging data

I have thousand lines of data...: A 1 B 2 C 3 D 4 E 5 A 21 B 22 C 23 D 24 E 25 A 31 B 32 C 33 D 34 E 35 ........... ON AND AND ON (3 Replies)
Discussion started by: bobo
3 Replies

8. Shell Programming and Scripting

need help in arranging the alias

Hello Guys, I have around 100 hosts setup as alias in my profile for easy sshing. alias ada='ssh -Y username@da.domain.com' alias ast='ssh -Y username@terix.domain.com' alias bb1='ssh -X username@ggserver.ns.domain.com' . . . . I now would like to use sshmenu software in which... (4 Replies)
Discussion started by: upengan78
4 Replies

9. Shell Programming and Scripting

Arranging files

Hi all, This is program to identify and arrange programs(scripts) based on their she-bang values to a folder with the same name. The parts of mkdir and copy and creating problems.I also doubt the use of hash...maybe some problems in it. Please help out debugging this. Code pasted at: Paste... (2 Replies)
Discussion started by: Vivek788
2 Replies

10. Shell Programming and Scripting

Help with arranging data file

Dears, I have the below data, sss-aaaaaa 111211 222222 33333 22222 1163111 sss-vvvvvv 111311 224522 335633 24322 111511 sss-cccccc 111221 224522 333333 24322 111511 sss-dddddd 111211 222222 33333 22345222 113111 I want to make them like ... (7 Replies)
Discussion started by: yahyaaa
7 Replies
Login or Register to Ask a Question