I have been looking everywhere for a solution and it seems as though awk may do the trick. I am very much a newbie in the awk scripting world but it seems to appear one of the best text parsing tools from what I've read on this forum.
Scenario:
I have about 50 cisco config files randomly named. I need to create a script that looks in each config file (*.cfg) located on the local drive in the same directory as the script for
interface Vlan227 <-- need one column to be the data after interface as long as it begins with interface Vlan
ip address 10.47.203.2/25 <-- need another column to be whatever is after ip address (if it even exists)
description <-- need this in its entirity (if it exists)
ip dhcp relay address 10.47.144.76 <-- need the address (could be more than one line up to 6)
or
ip helper-address 10.47.144.76 <-- need the address (could be more than one line up to 6)
I attached an example of one of the config files
My thought on approach would possibly be using a bash script calling awk
Any help figuring this out would be very educational and very helpful if you can add some comments on what the code is doing so I can wrap my old brain around it.
Thats incredible. Exactly what I was trying to do. Your script makes it look so easy. I really appreciate it. Thank You. Now I would like to try and dissect what you are doing so I can learn how its working.
For the description line, you shouldn't use $0 as is, but first remove $1 (which happens to be the string "description") from $0 like sub (" *" $1 " ", "", $0).
Is there a possible limitation on lines? Trying on another config and getting blank lines:
So I did a
It shows 159 lines since it also shows other interfaces besides just interface Vlan
example of results:
So to troubleshoot and trying to figure this out on my own in hopes to learn I started at print statements to validate the variables are being populated so I altered the code to look like this and the output is ugly but you can see there is stuff in there:
Am i approaching this correctly?
Greetings,
After a few hours of trial and error, I decide to ask for some help.
I am new to AWK and shell script, so please don't laugh :p
I made the below script, to gather data from some logs and have the output into a CSV file :
#!/bin/sh
#Script to collect Errors
... (9 Replies)
Hi all,
Is there any out there have a brilliant idea on how to export html table data as .csv or write to txt file with separated comma and also get the filename of link from every table and put one line per rows each table.
Please see the attached html and PNG of what it looks like.
... (7 Replies)
Hello All,
I have an input CSV file like below, where first row data can be in different position after every run of the tool, i.e. pzTest in below example is in column 1, but it can be also in 3 column and same for all the headers in the first row.
pzTest, pzExtract, pxUpdate, pzInfo... (1 Reply)
I am really shooting for the moon here but I really want to be able to break down our named.conf file into a CSV file so I can easily see what options are for each zone.
Here are two basic entries as examples:
zone "mywiseguys.com" {
type slave;
file... (9 Replies)
Hey guys,
I'm in the process of learning PHP and BASH scripting. I'm getting there, slowly ;)
I would like some help with parsing a CSV file. This file contains a list of hostnames, dates, and either Valid, Expired, or Expired Soon in the last column.
Basically, I want to parse the file,... (12 Replies)
I have been trying to find a good solution for this seemingly simple task for 2 days, and I'm giving up and posting a thread. I hope someone can help me out!
I'm on HPUX, using sqlplus, mailx, awk, have some other tools available, but can't install stuff that isn't already in place (without a... (6 Replies)
I am trying to parse a csv file in the below 'name-value pair' format and then use the values corresponding to the name.
Type:G,Instance:instance1,FunctionalID:funcid,Env:dev,AppName:appname... (6 Replies)
Hello people,
Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these... (3 Replies)