Need Script plz help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need Script plz help
# 1  
Old 03-02-2012
Need Script plz help

hi please help

i need script to merger columns

input file

Code:
a,bb,1234345234
a,bb,sdfsdfsdf
a,bb,xxxxxxxx
b,cc,12335353
b,cc,fdgfdghht
b,cc,yyyyyyy
c,22,sdfgsdfg
.
.
.
.

output file

Code:
a,bb,1234345234a,bb,sdfsdfsdfa,bb,xxxxxxxx
b,cc,12335353b,cc,fdgfdghhtb,cc,yyyyyyy
c,22,sdfgsdfg

Thanks in Advance

Last edited by methyl; 03-02-2012 at 09:35 AM.. Reason: please use code tags
# 2  
Old 03-02-2012
awk

Hi,

Try this one,

Code:
awk 'BEGIN{FS=",";ORS="";}{if(p!=$1 && NR != 1){print "\n"$0;}else{print;}p=$1;}END{print "\n";}' file

Cheers,
RangaSmilie
# 3  
Old 03-02-2012
What Operating System and version do you have and what Shell do you use?

What have you tried so far?

What is the real-world purpose of the script? The comma-delimited structure is broken in the output file.
# 4  
Old 03-02-2012
Thank you Ranga its working

---------- Post updated at 08:47 AM ---------- Previous update was at 08:45 AM ----------

hi ranga

i need to put onle line /n

like below

a,bb,1234345234a,bb,sdfsdfsdfa,bb,xxxxxxxx

b,cc,12335353b,cc,fdgfdghhtb,cc,yyyyyyy

c,22,sdfgsdfg

Thanks in advance

---------- Post updated at 09:00 AM ---------- Previous update was at 08:47 AM ----------

using UNIX
# 5  
Old 03-02-2012
Code:
# sed 'N;N;s/\n//g;s/$/\n/' infile
a,bb,1234345234a,bb,sdfsdfsdfa,bb,xxxxxxxx

b,cc,12335353b,cc,fdgfdghhtb,cc,yyyyyyy

c,22,sdfgsdfg

# 6  
Old 03-02-2012
thanks a lot working fine , Smiliecheers
# 7  
Old 05-23-2012
Code:
Habcd145623
D1,2,3,4,567
D1,2,,34568
Dr,r,rr
D3,33,3
D1,2,34,5,67
D12,34,56,7,89,900
T12344343

i need the line numbers where the total commas the line is not equal to 4 by omiting H, D starting Records

i need output as
Code:
3,4,5,7

Code:

i have done in for loop but it exits when one line record is wrong ...i tried by using awk i cant


Please give me the suggestion

Last edited by Scrutinizer; 05-23-2012 at 02:05 PM.. Reason: code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to do this Script PLZ?

HI all , i want to make an automatic script using if / while to search for files in folder and get the least by date and gzip them ( last 70 file ) /file/home/logs 30 files in 11/2012 45 files in 10/2012 30 files in 9/2012 10 files in 8/2012 so it get 10 + 30 + 30 ( from 10 )... (5 Replies)
Discussion started by: teefa
5 Replies

2. Shell Programming and Scripting

i'm new to shell can handle this script for me plz

Write a shell script named displayargs that prints FOUR lines. The first line tells the name that was used to invoke the script, the second line tells how many parameters there were, the third line tells what the last parameter was, and the fourth line tells what the first parameter was. For... (8 Replies)
Discussion started by: kedah160
8 Replies

3. Shell Programming and Scripting

Explain this AWK script plz

Hi frnds, one my frnds has given resolution for my problem as below. it working great , but i couldnt understand somethings in the script. Why ++ operator after the function calling. how these each block working. will each run for each input line sequencially or one block for all the lines... (9 Replies)
Discussion started by: Gopal_Engg
9 Replies

4. UNIX for Dummies Questions & Answers

Shell Script Help Plz

####################################################################### # #This script will perform the menu such as : list file, change catalog, #file check, # #This script was written in UNIX Shell Programming Language #... (3 Replies)
Discussion started by: shekhani
3 Replies

5. UNIX for Advanced & Expert Users

Script Not waiting....plz help

Hi All: I am trying to call a multi-step script from a script. here is the code #!/usr/bin/ksh util.sh <<EOF connect dump EOF I am able to run the script but it is disconnecting before the dump job is finished. The script util.sh does not provide any functionality to wait... (9 Replies)
Discussion started by: laxman123
9 Replies

6. Solaris

plz help me in writing a script

Hi all, I want to write a script which gather all files who where having a particular name.The script should run at the end of each month. The files(Audit and health files) are generated each day. I want to gather the files seperately into corresponding folders and so that i can ftp'ed... (3 Replies)
Discussion started by: Renjesh
3 Replies

7. Shell Programming and Scripting

script help plz

Hi, im trying to make a script which will look up every .c file in the current directory for the strings printf or fprintf. if found, the script adds the statement #include <stdio.h> at the beginning of the file but only if it doesnt alrdy have it included. How do i do that ?i know firstly, i need... (6 Replies)
Discussion started by: lohan
6 Replies

8. UNIX for Dummies Questions & Answers

unix script plz help

cdfcxvvbbvnbjmjnhjml. (1 Reply)
Discussion started by: sree11
1 Replies

9. Shell Programming and Scripting

Nee help debugging script..plz

I am having problems w/this script. Menu is not comming up to prompt me. I've worked on it for days and still cannot see the problem. Anyone can help, I would appreciate it. Possible problems with syntax and function calls. Thks... TMP=$tapemgr/rpts/tmp # TAPE MANAGER MAIN MENU while : do... (8 Replies)
Discussion started by: gzs553
8 Replies

10. UNIX for Dummies Questions & Answers

plz Help How should I configure cc compiler output file plz help???

i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies
Login or Register to Ask a Question