Sponsored Content
Full Discussion: awk read RS
Top Forums Shell Programming and Scripting awk read RS Post 302645567 by numele on Wednesday 23rd of May 2012 05:44:02 PM
Old 05-23-2012
awk read RS

I need to know if there is a way to use the while read command from a awk record. The record has 3 or 4 lines and I need the line to be all of the record instead of just each line of it.
Code:
nawk 'BEGIN {RS="!"} /atm pvc/ {print $0}' router.list | while read line
do
VP=`echo "$line" | egrep "atm pvc" | nawk '{print $4}'`
VC=`echo "$line" | egrep "atm pvc" | nawk '{print $5}'`
PROFILE=`echo "$line" | egrep "atm pvc" | nawk '{print $7}'`
ENACP=`echo "$line" | egrep "encapsulation"`
INTERFACE=`echo "$line" | egrep "ip description" | nawk '{print $3}'`
echo "atm pvc $VP $VC profile dsl-$PROFILE $ENCAP"
if [[ $ENCAP == "encapsulation pppoe" ]] ; then
echo "bind authentication pap maximum 1"
else
echo "bind interface $INTERFACE [ADSL]"
fi
done

An example of the input file is:
Code:
interface atm 1/0.20292 point-to-point
 atm pvc 100020292 2 292 aal5snap 768 768 10
 encapsulation pppoe
! 
interface atm 1/0.20292.1
 encapsulation ppp
 ppp authentication pap
 profile any "prof-pppoe"
! 
interface atm 1/0.20293 point-to-point
 atm pvc 100020293 2 293 aal5snap 1500 1500 10
 encapsulation pppoe
! 
interface atm 1/0.20293.1
 encapsulation ppp
 ppp authentication pap
 profile any "prof-pppoe"
! 
interface atm 1/0.20294 point-to-point
 atm pvc 100020294 2 294 aal5snap 1500 1500 10
 encapsulation pppoe
! 
interface atm 1/0.20294.1
 encapsulation ppp
 ppp authentication pap
 profile any "prof-pppoe"
! 
interface atm 1/0.20295 point-to-point
 atm pvc 100020295 2 295 aal5snap 3000 3000 10
 encapsulation pppoe
! 
interface atm 1/0.20295.1
 encapsulation ppp
 ppp authentication pap
 profile any "prof-pppoe"
! 
interface atm 1/0.20296 point-to-point
 atm pvc 100020296 2 296 aal5snap 6000 6000 10
 encapsulation pppoe
! 
interface atm 1/0.20296.1
 encapsulation ppp
 ppp authentication pap
 profile any "prof-pppoe"
! 
interface atm 1/0.20297 point-to-point
 atm pvc 100020297 2 297 aal5snap 1500 1500 10
 encapsulation pppoe
! 
interface atm 1/0.20297.1
 encapsulation ppp
 ppp authentication pap
 profile any "prof-pppoe"
! 
interface atm 1/0.20298 point-to-point
 atm pvc 100020298 2 298 aal5snap 3000 2900 10
 encapsulation bridge1483
 ip description AAAService-1/0-2-298 [local]
 ip address 192.168.217.86 255.255.255.248
!

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with awk - read from file

Hi, I've got a file like the following: Starting to process segment 0 (and symmetry related segments) Number of (cancelled) singularities: 0 Number of (cancelled) negative numerators: 0 Segment 0: 5.49secs Starting to process segment 1 (and symmetry related segments) Number of... (7 Replies)
Discussion started by: giorgos193
7 Replies

2. Shell Programming and Scripting

File Read using awk

Hi, I need to read two colums(4th and 5th) from a file and do some manipulation Input file is 401500 IOC Q 14 14 406200 LC Q 1 1 410124 IOC Q 5 4 410124 LC Q 11 8 410132 IOC Q 230 229 410148 IOC Q ... (3 Replies)
Discussion started by: rejirajraghav
3 Replies

3. Shell Programming and Scripting

How to re-read a file in AWK

Hi , i am having some problem with re-reading the same file in AWK. here is the scenario. function 1 { some_string > " file1 " # i have redirected output to file1. ........... ........ } Now in function 2 { ... (1 Reply)
Discussion started by: madhaviece
1 Replies

4. Shell Programming and Scripting

Using awk to read a field

I am trying to output the total number of records that have name and address within there specific fields i.e. $6 (surname) $9 (address). The file that redirects in is a csv file. The code is wrong somewhere as i have another awk similar to this that reads in the same file and that works... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

5. UNIX for Dummies Questions & Answers

Using Awk within awk to read all files in directory

I am wondering if anyone has any idea how to use an awk within awk to read files and find a match which adds to count. Say I am searching how many times the word crap appears in each files within a directory. How would i do that from the command prompt ... thanks (6 Replies)
Discussion started by: flevongo
6 Replies

6. Shell Programming and Scripting

Read content between xml tags with awk, grep, awk or what ever...

Hello, I trying to extract text that is surrounded by xml-tags. I tried this cat tst.xml | egrep "<SERVER>.*</SERVER>" |sed -e "s/<SERVER>\(.*\)<\/SERVER>/\1/"|tr "|" " " which works perfect, if the start-tag and the end-tag are in the same line, e.g.: <tag1>Hello Linux-Users</tag1> ... (5 Replies)
Discussion started by: Sebi0815
5 Replies

7. Shell Programming and Scripting

Awk and read bailing out

Hi All, Can some body help me in this to work #!/bin/ksh nof=`wc -l outFile_R.out | sed -e 's/*//g' ` no_of_lines=`expr $nof - 0` z=1 while ] do cat outFile_R.out | awk -v I="$z" 'NR==I { print $0 }' | read from_date to_date id echo "executing $from_date... (2 Replies)
Discussion started by: sol_nov
2 Replies

8. Shell Programming and Scripting

How to use awk with while read line

Hi All, Content of mydatafile- Name Age -------------- --------------- Raju P 20 years Hari 25 years Priya S 30 years I need output like- The age of Raju P is 20 years The age of Hari is 25 years The age of Priya S is... (3 Replies)
Discussion started by: NARESH1302
3 Replies

9. Shell Programming and Scripting

read the variable with awk

final.txt file contains SY10020021 SY10023077 3199 4 803.815 11884 4 1825.22 2.2707 say set FIRSTLINE = SY10020021 set SECONDLINE=SY10023077 cat final.txt | awk '{if($1==${FIRSTLINE} & $2==${SECONDLINE}){print $9}else{print "ll"}}'..............this should give me value... (1 Reply)
Discussion started by: Indra2011
1 Replies

10. Shell Programming and Scripting

Read a file using awk for a given no of lines.

Hi, how do i read a file using awk for a given no of line? e.g 1. read only first 50 line. 2. read starting from line 20 to line 60.. thanks in advance. -alva (8 Replies)
Discussion started by: alvagenesis
8 Replies
PPPOE-SETUP(8)						      System Manager's Manual						    PPPOE-SETUP(8)

NAME
pppoe-setup - Shell script to configure Roaring Penguin PPPoE client SYNOPSIS
pppoe-setup DESCRIPTION
pppoe-setup is a shell script which prompts you for various pieces of information and sets up an /etc/ppp/pppoe.conf configuration script for the pppoe-start, pppoe-stop and pppoe-connect scripts. AUTHOR
pppoe-setup was written by David F. Skoll <dfs@roaringpenguin.com>. The pppoe home page is http://www.roaringpenguin.com/pppoe/. SEE ALSO
pppoe(8), pppoe-start(8), pppoe-stop(8), pppoe-connect(8), pppd(8), pppoe.conf(5), pppoe-status(8), pppoe-sniff(8), pppoe-relay(8), pppoe- server(8) 4th Berkeley Distribution 21 February 2000 PPPOE-SETUP(8)
All times are GMT -4. The time now is 05:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy