473,397 Members | 1,950 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,397 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 1579
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.