![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| if [ $NOWDATE -gt $STARTDATE ] , date comparison correct syntax? | danpaluska | Shell Programming and Scripting | 1 | 2 Weeks Ago 06:24 PM |
| Plz correct my syntax of shell script | girish.batra | Shell Programming and Scripting | 2 | 06-06-2008 06:36 AM |
| Pls correct the "if" syntax | ganapati | Shell Programming and Scripting | 5 | 07-31-2006 02:07 AM |
| correct syntax for using "grep regex filename" ? | yongho | UNIX for Dummies Questions & Answers | 2 | 06-13-2005 02:44 PM |
| Correct Syntax For Calling Shell Script in Perl Module | mh53j_fe | Shell Programming and Scripting | 4 | 06-08-2005 10:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
hi, i'm a beginner in Linux, actually i use andLinux,
i have a data file with 11 columns Code:
170 N SER T 25 56.962 42.701 -133.423 1.00 87.04 N 171 CA SER T 25 57.076 41.790 -132.280 1.00 86.65 C 172 C SER T 25 57.766 40.492 -132.692 1.00 87.52 C 173 O SER T 25 58.653 39.988 -131.992 1.00 86.59 O 174 CB SER T 25 55.694 41.451 -131.730 1.00 85.78 C 175 OG SER T 25 54.981 40.607 -132.622 1.00 77.49 O i tried several time only for C but doesn't work Code:
{
atom = $11
if ( atom == " C " )
{
print $11 12
}
else
{
print $11 "no"
}
}
thanks Last edited by Franklin52; 2 Weeks Ago at 05:52 PM.. Reason: Adding code tags and aligning code |
|
||||
|
Code:
awk '{
if ($NF=="N") {print $11,"14"}
else if ($NF=="C") {print $11,"12"}
else if ($NF=="O") {print $11,"16"}
else {print $11,"no"}
} ' urfile
N 14
C 12
C 12
O 16
C 12
O 16
Last edited by rdcwayx; 2 Weeks Ago at 11:28 PM.. |
|
||||
|
Code:
sed -e 's/N$/N12/' -e 's/C$/C14/' -e 's/O$/O16/' |
| Bits Awarded / Charged to summer_cherry for this Post | |||
| Date | User | Comment | Amount |
| 2 Weeks Ago | Anonymous | Always see your reply with perl script, and now i know, you are shell script expert also. | 100 |
|
||||
|
reply
Thanks so much, but it still no working, if i prepare a file test.awk and i call it by command awk -f test.awk , it writes a column of "no". And if i try to write the command directly on the terminal, it writes nothing and the terminal become useless.
![]() ---------- Post updated at 12:59 PM ---------- Previous update was at 10:56 AM ---------- thanks a lot, with your suggestion it works. thank you. Elsa ![]() |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|