473,625 Members | 3,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

60 New Member
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 1589
ghostdog74
511 Recognized Expert Contributor
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
coaxfiber
60 New Member
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
3480
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 by adding a WebReference, since it does not allow me to keep state (cookiecontainer) or to specify functions on the classes (like if i want to override the ToString() function on a class from my webservice). So the only way i can see how i can get...
1
1381
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 ".Net" environment, over an intranet / lan environment. the first alternative is "Asp.Net".. though Microsoft is trying to push it very hard, to me the idea seems to be very wrong. I think that client code should be seperated from server code....
16
2524
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 uses IE to talk with a server. The user on the client (IE) sees an ASP net page containing a TextBox. He can write some text in this text box and push a submit button.
83
7799
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 some other ploblems which i can not correct.I would appreciated if someone take a look at my programm so as to help me.I tried many times to find out where my mistakes are but i didn't manage something. I have made some comments due to the programm...
0
5557
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 ******************************************************** For this teeny job, please refer to: http://feeds.reddit.com/feed/8fu/?o=25
0
8256
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8189
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.