Help with data reformat if share share content


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with data reformat if share share content
# 1  
Old 11-13-2011
Help with data reformat if share share content

Input data:
Code:
read1_data1
read1_data1
read2_data1
read3_data1
read4_data1
read4_data1
read4_data1
read5_data1
.
.

Desired output result:
Code:
read1_data1
read1_data2
read2_data1
read3_data1
read4_data1
read4_data2
read4_data3
read5_data1

If the content share the same "read". Then continue add 1 at the "data"
Thanks for any advice.
# 2  
Old 11-14-2011
Code:
awk -F _ '{gsub(/[0-9]/,"",$2);b[$1 FS s]++;print $1 FS $2 b[$1 FS s]}' infile

This User Gave Thanks to rdcwayx For This Post:
# 3  
Old 11-14-2011
Code:
$
$
$ cat f39
read1_data1
read1_data1
read2_data1
read3_data1
read4_data1
read4_data1
read4_data1
read5_data1
$
$
$ perl -plne '/^(.*)(\d+)$/; $_=$1.++$x{$1}' f39
read1_data1
read1_data2
read2_data1
read3_data1
read4_data1
read4_data2
read4_data3
read5_data1
$
$

tyler_durden
# 4  
Old 11-14-2011
Code:
for seddt in $(sed 's/data[0-9]//' file|sed '$!N; /^\(.*\)\n\1$/!P; D'); do for((j=1;j<=$(sed -n "/$seddt/=" file|sed -n '$=');j++));do echo "${seddt}data$j";done;done
read1_data1
read1_data2
read2_data1
read3_data1
read4_data1
read4_data2
read4_data3
read5_data1

regards
ygemici
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help to print the line that share exactly same with column one content

Input file : AAAG TC AACCCT AACCCT AACCCT AACCCT TCTG TCTG TCTG AC AC TCTG TCTG AC AC AC AC AC AGTG AC AGTG TCC Desired output file : AACCCT AACCCT AACCCT AACCCT AC AC I would like to print out the line that share exactly same as the first column data content. Column one data... (4 Replies)
Discussion started by: perl_beginner
4 Replies

2. Red Hat

NFS share

Hi, I have an NFS server, i want to mount that nfs share which is having around 500GB to my client system. But my client system doesnt have any free space, is it possible to mount that nfs share in my client. Regards, Mastan (1 Reply)
Discussion started by: mastansaheb
1 Replies

3. Shell Programming and Scripting

Help with keep the record with share content

Input file: 1234 USA date 3421 USA date 3421 USA content 1234 USA1 date 34 USA1 content 1234 USA2 Sun 34 USA2 Sun 43 USA2 Sun 345 USA2 date 435 USA2 date1 Output file: 1234 USA date 3421 USA date 1234 USA1 date 1234 USA2 Sun 34 USA2 Sun 43 USA2 Sun (0 Replies)
Discussion started by: perl_beginner
0 Replies

4. Shell Programming and Scripting

Help with data rearrangement based on share same content

Input file data_2 USA data_2 JAPAN data_3 UK data_4 Brazil data_5 Singapore data_5 Indo data_5 Thailand data_6 China Desired output file data_2 USA/JAPAN data_3 UK data_4 Brazil data_5 Singapore/Indo/Thailand data_6 China I would like to merge all data content that share same... (2 Replies)
Discussion started by: perl_beginner
2 Replies

5. Shell Programming and Scripting

Help with reformat data content

input file: hsa-miR-4726-5p Score hsa-miR-483-5p Score hsa-miR-125b-2* Score hsa-miR-4492 hsa-miR-4508 hsa-miR-4486 Score Desired output file: hsa-miR-4726-5p Score hsa-miR-483-5p Score hsa-miR-125b-2* Score hsa-miR-4492 hsa-miR-4508 hsa-miR-4486 Score ... (6 Replies)
Discussion started by: perl_beginner
6 Replies

6. AIX

Need help with Windows Share please

I have a windows 2003 server with services for unix installed I have create a folder c:\nfsshare and set it as an nfs share named nfsshare. now I am trying to mount it from my aix system using mount <server ip>:/nfsshare /mnt the filesystem mounts , but I cannot change into /mnt, I get a... (4 Replies)
Discussion started by: bbbngowc
4 Replies

7. IP Networking

how to share with windows

i m using Linux Mint on my computer and i m the server of shared Internet connection with windows machines. Internet sharing is working well with all the machines but file sharing is not working well. I can access the shared folders of other system with windows machine the windows machines cannot... (1 Reply)
Discussion started by: giri.nitp
1 Replies

8. AIX

share with cifs

Im trying to share a directory with cifs my aix box with a windows server. but when I try to mount mount -v cifs -n 172.19.90.240/suc_user/tommy /directory /directory1/directory1 I got this error There was an error connecting the share or the server. Make sure the lsdev command shows that... (1 Reply)
Discussion started by: lo-lp-kl
1 Replies

9. HP-UX

how to share filesystem

closed this (0 Replies)
Discussion started by: eykyn17
0 Replies
Login or Register to Ask a Question