Modifying data within the same line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Modifying data within the same line
# 1  
Old 07-06-2010
Modifying data within the same line

My file looks like this
Quote:
;1.0
26;27;30;39;45;46;47;48;51;54;55;56;57;58;59;60;61;62;63;64;65;66;68;69;71;72;73;74;76;77;78;80;82;8 3;84;85;86;87;88;89;90;91;93;94;95;96;97;98;99;102;103;104;105;106;107;108;109;110;114;115;116;119;1 20;121;124;133;136;141;145;147;150;151;157;
10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;1 0;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10 ;10;10;10;10;10;10;
>GHXCZCC01AJ9EA Freq 59;1;;;;
GTCTGGACCCGGGGCGAGGCTGTCGCGCCGGTTTCATGCCCGCGTCTCCCACCGTGCGGCTGCAGGTTATAAA
>GHXCZCC01ANKKF Freq 33;1;;;;
GTCTGGACCCGGGGCGAGGCTGTCGCGCCGGTTTCATGCCCGCGTCTCCCACCGTGCGGCTGCAGGTTATAGA
>GHXCZCC01AQARH Freq 22;1;;;;
GTCTGGACCCGGGGTGAGGCTGTCGCGCCGGTTCCCTGCCCGCGTCTCCCACCATGCGGCTGCAGGTTATAGA
>GHXCZCC01AL97H Freq 21;1;;;;
GTCTGGACCCGGGGTGAGGCTGTCGCGCCGGTTTCATGCCCGCGTCTCCCACCGTGCGGCTCCAGGTTATAGA
>GHXCZCC01AO1HG Freq 313;1;;;;
GTCTGGACCCGGGGCGAGGCTGTCGCGCCGGTTCCCTGCCCGCGTCTCCCACCATGCGGCTGCAGGTTATAGA
But I need to move the frequency value (Freq) to the second position, leaving intact the numbers at the top. The resulting file should look like this
Quote:
;1.0
26;27;30;39;45;46;47;48;51;54;55;56;57;58;59;60;61;62;63;64;65;66;68;69;71;72;73;74;76;77;78;80;82;8 3;84;85;86;87;88;89;90;91;93;94;95;96;97;98;99;102;103;104;105;106;107;108;109;110;114;115;116;119;1 20;121;124;133;136;141;145;147;150;151;157;
10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;1 0;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10;10 ;10;10;10;10;10;10;
>GHXCZCC01AJ9EA ;59;;;;
GTCTGGACCCGGGGCGAGGCTGTCGCGCCGGTTTCATGCCCGCGTCTCCCACCGTGCGGCTGCAGGTTATAAA
>GHXCZCC01ANKKF ;33;;;;
GTCTGGACCCGGGGCGAGGCTGTCGCGCCGGTTTCATGCCCGCGTCTCCCACCGTGCGGCTGCAGGTTATAGA
>GHXCZCC01AQARH ;22;;;;
GTCTGGACCCGGGGTGAGGCTGTCGCGCCGGTTCCCTGCCCGCGTCTCCCACCATGCGGCTGCAGGTTATAGA
>GHXCZCC01AL97H ;21;;;;
GTCTGGACCCGGGGTGAGGCTGTCGCGCCGGTTTCATGCCCGCGTCTCCCACCGTGCGGCTCCAGGTTATAGA
>GHXCZCC01AO1HG ;313;;;;
GTCTGGACCCGGGGCGAGGCTGTCGCGCCGGTTCCCTGCCCGCGTCTCCCACCATGCGGCTGCAGGTTATAGA
Thanks in advance!
# 2  
Old 07-06-2010
Do you want to remove Freq from all the lines ?

Can you highlight the changes you need?
# 3  
Old 07-06-2010
Code:
perl -ple 's/Freq (\d+);1/;$1/' file > outfile

This User Gave Thanks to bartus11 For This Post:
# 4  
Old 07-06-2010
bartus11

You are the man!
Thanks one more time!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Modifying text file records, find data in one place in the record and print it elsewhere

Hello, I have some text data that is in the form of multi-line records. Each record ends with the string $$$$ and the next record starts on the next line. RDKit 2D 15 14 0 0 0 0 0 0 0 0999 V2000 5.4596 2.1267 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 ... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

2. Shell Programming and Scripting

Modifying bash script to take each line in a file and execute command

I need to modify a bash script to to take each line in a file and execute command. I currently have this: #!/bin/bash if ; then echo "Lipsa IP"; exit; fi i=1 ip=$1 while ; do if ; then rand=`head -$i pass_file | tail -1` user=`echo $rand | awk '{print $1}'` pass=`echo $rand | awk '{print $2}'`... (3 Replies)
Discussion started by: galford
3 Replies

3. Shell Programming and Scripting

Modifying file from command line using Perl

Hi all, I am having a slight issue updating a file using perl from the command line I need some help with. The item is: DATA_FILE_TYPE=FULL When I run the below command /usr/bin/perl -p -i -e "s/DATA_FILE_TYPE=/DATA_FILE_TYPE=APPEND/g" processfile.cfg It looks to be... (2 Replies)
Discussion started by: kstevens67
2 Replies

4. Shell Programming and Scripting

Help in adding a data after a particular line of data in a file.

Hi.. I'm into a bump after trying to solve this prob.. i've a file with contents like below. <blankline> 'pgmId' : 'UNIX', 'pgmData' : 'textfile', 'author' : 'admin', ....... Now i'm trying to insert a new data after pgmId. so the final output will be... (7 Replies)
Discussion started by: arjun_arippa
7 Replies

5. Shell Programming and Scripting

Searching for a particular string and modifying text within block of data

Hi Forum. Is there a quick way to do the following search/replace within a block of data? I tried to google the solution but didn't really know what to look for. I have the following text file (I want to search for a particular string "s_m_f_acct_txn_daily_a1" and replace the... (5 Replies)
Discussion started by: pchang
5 Replies

6. UNIX for Dummies Questions & Answers

Modifying a particulae data in a line contained in File

Hi, I have a file containing data: systemname/userid/password/comment systemname1/userid1/password1/comment1 systemname2/userid2/password2/comment2 I want to modify the "password" using script. Can anybody help me with this problem?:confused: (2 Replies)
Discussion started by: pgarg1989
2 Replies

7. Shell Programming and Scripting

modifying a awk line

Hi, I want to print specific columns (from 201 to 1001). The line that I am using is listed below. However I also want to print column 1. So column 1 and 201 to 1001. What modifcations do I need to make? Code: awk -F'\t' 'BEGIN {min = 201; max = 1001 }{for (i=min; i<=max; i++) printf... (5 Replies)
Discussion started by: phil_heath
5 Replies

8. Shell Programming and Scripting

Modifying a line

Hi, I am having trouble modifying this line. It is because there is a space that I dont know how to deal with. So the file looks like this >YM4911-Contig4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX >YM4915-Contig5 MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM There are two spaces between contig#... (6 Replies)
Discussion started by: phil_heath
6 Replies

9. Shell Programming and Scripting

Formatting a text file to get data in exact line by line

I have my data something like this SERIAL FIRSTOCCURRENCE NETPROTOCOL 1947430693 07/01/2009 05:16:40 FR SERIAL FIRSTOCCURRENCE NETPROTOCOL 1947430746 07/01/2009 05:18:05 FR I want the output as follows.... (1 Reply)
Discussion started by: rdhanek
1 Replies

10. Shell Programming and Scripting

compare data line by line from a file

Hi there How can I compare data line by line from a file? I need to compare the second value with the fourth to know if they are different. If those values are different, I require to send my first value to the output until the complete file has been read. This is my file: 0 FALSE... (1 Reply)
Discussion started by: loperam
1 Replies
Login or Register to Ask a Question

Featured Tech Videos