473,323 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Help Using AWK or any other idea that can make this easy:

Hi, I'm working with my script like this.
First file -> help.sh - Below the text contained in the file:
--------------------------------------------------------------------------------
#!/bin/ksh
clear
awk -f help.awk help.txt > help.out
cat out

Secong file -> help.txt - Below the text contained the file:
7706 *** BSC South
UH05NPNDN8 (formerly
PLMN-PLMN/BSC-48637/BCF-70
BTS O&M LINK FAILURE
Started 2007-04-23 18:06:58

Third File -> help.awk - Below the text contained the file:
{
if ($1 == "BTS")
{
x = ""
x = substr($1,1,3)
print ""x""
}
}
-------------------------------------------------------
Output -> BTS. This means that if first word encounter BTS then it will go to the 'substr'. This works only for a multiple word in a line, but this is my problem.
If you can see this from my file help.txt 'PLMN-PLMN/BSC-48637/BCF-70' ,this is considered only as one word in a line. Here is what I want to get, that my output is '-BCF-70'. What should I represent in $1=="?????" to be the basis of my search string if there are no other words that I could use to make it.Can I use a delimiter,how? I talked to someone about this, he told me that I can use $0 , but how can I use that one here?..Thanks.

FYI.
May 3 '07 #1
2 1576
ghostdog74
511 Expert 256MB
Hi, I'm working with my script like this.
First file -> help.sh - Below the text contained in the file:
--------------------------------------------------------------------------------
#!/bin/ksh
clear
awk -f help.awk help.txt > help.out
cat out

Secong file -> help.txt - Below the text contained the file:
7706 *** BSC South
UH05NPNDN8 (formerly
PLMN-PLMN/BSC-48637/BCF-70
BTS O&M LINK FAILURE
Started 2007-04-23 18:06:58

Third File -> help.awk - Below the text contained the file:
{
if ($1 == "BTS")
{
x = ""
x = substr($1,1,3)
print ""x""
}
}
-------------------------------------------------------
Output -> BTS. This means that if first word encounter BTS then it will go to the 'substr'. This works only for a multiple word in a line, but this is my problem.
If you can see this from my file help.txt 'PLMN-PLMN/BSC-48637/BCF-70' ,this is considered only as one word in a line. Here is what I want to get, that my output is '-BCF-70'. What should I represent in $1=="?????" to be the basis of my search string if there are no other words that I could use to make it.Can I use a delimiter,how? I talked to someone about this, he told me that I can use $0 , but how can I use that one here?..Thanks.

FYI.
you did not specify a field separator, so by default AWK use spaces. You are checking for the first field $1 and see whether its "BTS" , and if it is , you also want to substr this field starting from index 1, which in the end you just want to get "BTS". That's where i don't understand what you want. If you just want to get "BTS" , then you don't need the substr. Because AWK works best on structured data, and because you have a requirement that "breaks" it, maybe you can try to check for the number of fields,
Expand|Select|Wrap|Line Numbers
  1. if ( NF ==1) .....
  2.  
this will check for one whole line. you can get your BCF-70 by doing things like substr etc ....
May 4 '07 #2
Sir,

Thanks for your opinion. I had tried some thing that worked in my script. But still your idea gives me an idea.

-coax
May 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Benne Smith | last post by:
Hi, I have three enviroments; a development, a testing and a production enviroment. I'm making a big application (.exe), which uses alot of different webservices. I don't use the webservices...
1
by: nico1469 | last post by:
Hello all, Once windows mmi programming was very easy - vb forms.. nice & easy. nowdays, our customers have became IE freaks !!! So, my question is, what is the best way to develop mmi in the...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
83
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.