![]() |
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 |
| Shell script to search through numbers and print the output | cdfd123 | Shell Programming and Scripting | 8 | 10-30-2007 04:40 PM |
| output only numbers from mixed string | nortypig | Shell Programming and Scripting | 10 | 08-29-2006 10:30 PM |
| Adding a column of numbers | Khoomfire | UNIX for Advanced & Expert Users | 1 | 01-18-2006 04:55 AM |
| formatting output in human readable numbers | ghazi | Shell Programming and Scripting | 11 | 01-10-2005 01:31 PM |
| how to sum numbers in column | iahveh | Shell Programming and Scripting | 1 | 09-30-2004 07:50 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
The easiest way that I can think of is to use sed(1) rather than a shell if statement. It's quite simple. Your output is saved in file but can also be piped into the sed command.
# cat file | sed -e "s/^\([0-9][0-9]*\) 4 /\1 Major /" -e "s/^\([0-9][0-9]*\) 5 /\1 Critical /" 9041 Major 9041 NTX0322R_IDBEACHBRD 32555 Critical 32555 NOK3410R_IZNEMIAMI 64586 Major 64586 PTX389PR_IVSEBRNVIL 1176 Major 1176 NTX1401R_IHCENTERFI 470 Major 470 NTX0182R_IDOOOI35_U 62737 Major 62737 PTX324PR_ICN_ALICE 63715 Major 63715 PTX569PR_IWATLANTA 65711 Critical 65711 PTX123PR_IBSLUMBERT 69746 Major 69746 NTX1822R_IHKATYHAWK 28013 Major 28013 NTX1407R_IHFONVILLA 448 Major 448 NTX0130R_IDGARLAND To add additional value translations, just and another "-e script" option. The syntax is -e 's/^\([0-9][0-9]*\) number /\1 string /" which says, on a line starting with one or more digits, then a space, another number, and one more space, substitute with the original starting digits, a space, a new string and a space. |
|
|||||
|
thanks but sed is an easy fix..
I am trying to get a bit more into the arguementive script, because I have another script I am working on and sed would become a problem. I would like to keep it simple and neat. I apprecate the reply though and any more details will be very help full. Thanks again. I am just looking to get the understanding of a simple if statement. I am one that will not stop until I complete something that has been stumping me. This if statement has, I have been battling now going on 20hrs straight.
Thanks Get ur Done.| |
|
|||||
|
awk ?
Now i am pretty familar with awk but it appears you are using it in a csh format. Am I mistaken? I ihave payed with it abit and continuiously get a awk statement failure.
It appears it woud work can you help me a bit more by giving me example using my script above. I have been negecting my house work. I am a singe father, so you know the wash is stacked, and the dished are growing, but I am determinded to competed this script before I wak into work tomorrow. My co workers and boss are all ignorate to scripting and see no reason of logic behind using it. they think I am crazy, I have worked in telecom for 6 years, and never did I want, have, or even used a gui point and click. There is no CLI with the network I am on. Moto got them locked to a GUI patform. So I have taken it apon my mysef to dig out of informix / dbaccess and use the mib to get accual and factual data. Long story short, it wil.l feel goood to rub this script it there face, that they have snickered amoung them seleves saying it could not be done. Thanks 4 everyones support .| |
|
||||
|
Quote:
Try this in your script: Code:
echo $tacg|awk '{ ($2 == 4)? $2 = "Major": $2 = "Critical"} {print}'
Code:
echo $tacg
f [ "" = "4" ]
then {
="Major"
}
fi
if [ "" = "5" ]
then {
="Critical"
}
fi
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|