The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to get following output in perl email-lalit Shell Programming and Scripting 1 08-08-2008 02:20 PM
Set a variable from awk output Cranie UNIX for Dummies Questions & Answers 3 10-11-2007 10:39 AM
To store the output in a variable Sudhakar333 Shell Programming and Scripting 2 07-10-2007 09:45 AM
how to output awk to a variable bashirpopal UNIX for Dummies Questions & Answers 4 04-02-2003 12:02 PM
Saving Perl scrpits in a UNIX Shell hagrid UNIX for Dummies Questions & Answers 3 06-21-2001 01:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-09-2008
userix userix is offline
Registered User
  
 

Join Date: May 2008
Posts: 21
Code:
for (@test)
{
   $last = `awk '/OXT/{print \$4}' $_`;
   $lastnum = `awk '/OXT/{print \$5}' $_`;
   system("sed -i -e '/O    ${last}    ${lastnum}/{s/-0.51000\$/-0.25500/;}' $_");
   system("sed -i -e '/OXT  ${last}    ${lastnum}/{s/-0.67000\$/-0.25500/;}' $_");
}
Thanks guys for your help. The variables are saving the awk output correctly, but when I try to use it in the following sed commands to replace the values shown, it fails.

This is what I want in the end: Find the line that contains OXT and grab the 4th and 5th values and save them to the variables indicated. Then I want to locate the lines that contain OXT followed by the 4th column value (GLY in this case) and by the 5th column value (319 in this case) and replace the number in the last column with the value shown in my sed line. Then I need to make the same replacement with the line that contains O followed by the 4th column value (GLY) and then by the 5th column value (319).

Below is a segment of a single file that I need to make the 2 replacement in. The bolded values are the numbers I need to replace with the values shown in the sed line. The thing is, the line that contains the O might not be next to the OXT line. It could be a random numbers of lines above. Each file in my set is the amino acid sequence and connectivity of different proteins. So the format of each file is uniform, but the actual data is different. Each file will have a single line that contains OXT, which is always located in the last amino acid residue. So I get the residue abberviation and number of the last amino acid by storing the 4th and 5th column value. Then I need to locate the O (oxygen) that is also located in the last residue (GLY 319) in the example file below and make the replacement of the last column value for this line and the line that contains OXT.

Pardon my poor programming mannerisms and improper perl usage, but I can better understand what is going on when I use awk and sed in my Perl script.


Code:
   ATOM    4539 HCB   LEU    318   -7.05103  -5.58173  17.60062 H_     1 0  0.09000
   ATOM    4540 HCB   LEU    318   -7.27904  -5.68284  15.87021 H_     1 0  0.09000
   ATOM    4541  CG   LEU    318   -7.65157  -7.53041  16.94206 C_3    4 0 -0.09000
   ATOM    4542 HCG   LEU    318   -6.58580  -7.79332  16.96207 H_     1 0  0.09000
   ATOM    4543  CD1  LEU    318   -8.26957  -8.08733  18.25040 C_3    4 0 -0.27000
   ATOM    4544 HCD1  LEU    318   -9.36063  -8.06637  18.20792 H_     1 0  0.09000
   ATOM    4545 HCD1  LEU    318   -7.95865  -9.12417  18.39911 H_     1 0  0.09000
   ATOM    4546 HCD1  LEU    318   -7.94214  -7.50413  19.11073 H_     1 0  0.09000
   ATOM    4547  CD2  LEU    318   -8.24821  -8.25377  15.71317 C_3    4 0 -0.27000
   ATOM    4548 HCD2  LEU    318   -7.75464  -7.91803  14.79952 H_     1 0  0.09000
   ATOM    4549 HCD2  LEU    318   -8.10485  -9.33270  15.79871 H_     1 0  0.09000
   ATOM    4550 HCD2  LEU    318   -9.31410  -8.05348  15.62518 H_     1 0  0.09000
   ATOM    4551  N    GLY    319   -8.71770  -2.77439  16.71834 N_R    3 0 -0.47000
   ATOM    4552 HN    GLY    319   -8.69152  -2.87454  15.75858 H___A  1 0  0.31000
   ATOM    4553  CA   GLY    319   -8.48831  -1.42062  17.17743 C_3    4 0 -0.02000
   ATOM    4554 HCA   GLY    319   -9.23650  -1.16420  17.93092 H_     1 0  0.09000
   ATOM    4555 HCA   GLY    319   -8.65103  -0.75119  16.33306 H_     1 0  0.09000
   ATOM    4556  C    GLY    319   -7.14757  -1.08823  17.71950 C_R    3 0  0.51000
   ATOM    4557  O    GLY    319   -6.15276  -1.84709  17.63535 O_2    1 2 -0.51000
   ATOM    4558  OXT  GLY    319   -7.00093  -0.12662  18.51114 O_2    1 2 -0.67000
   45 FORMAT CONECT (a6,12i6)
  #2 (permalink)  
Old 10-09-2008
a2156z a2156z is offline
Users Awaiting Email Confirmation
  
 

Join Date: Oct 2008
Posts: 30
why not split?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0