Sponsored Content
Full Discussion: Count lines in section
Top Forums Shell Programming and Scripting Count lines in section Post 302959012 by sharong on Wednesday 28th of October 2015 04:13:57 AM
Old 10-28-2015
Count lines in section

I am tiring to cont numbers of line between the "!" in CISCO routers
I have no problem to extract the input and change the empty line with !

Code:
!
5                Cable5/0/1 U0    4            
5                Cable5/0/1 U1    4            
!
5                Cable5/0/1 U2    4            
5                Cable5/0/1 U7    4            
9                Cable5/0/2 U0    8            
!
9                Cable5/0/2 U1    8            
!
9                Cable5/0/2 U4    8            
9                Cable5/0/2 U5    8            
!

The output will be
Code:
2
3
1
2

And another question
I need to get the content of the line for example
I need to get al the section wit 2 lines

The output will be

Code:
5                Cable5/0/1 U0    4            
5                Cable5/0/1 U1    4  

9                Cable5/0/2 U4    8            
9                Cable5/0/2 U5    8


Thanks
Sharon

Last edited by Don Cragun; 10-28-2015 at 06:23 AM.. Reason: Add CODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to count lines - ignoring blank lines and commented lines

What is the command to count lines in a files, but ignore blank lines and commented lines? I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end. Here is an example of what I would like my... (6 Replies)
Discussion started by: kthatch
6 Replies

2. Shell Programming and Scripting

Removing Duplicate Lines per Section

Hello, I am in need of removing duplicate lines from within a file per section. File: ABC1 012345 header ABC2 7890-000 ABC3 012345 Header Table ABC4 ABC5 593.0000 587.4800 ABC5 593.5000 587.6580 <= dup need to remove ABC5 593.5000 ... (5 Replies)
Discussion started by: petersf
5 Replies

3. Shell Programming and Scripting

Placing Duplicate Lines per section into another file

Hello, I need help in putting duplicate lines within a section into another file. Here is what I'm struggling with: Using this file “data.txt”: ABC1 012345 header ABC2 7890-000 ABC3 012345 Header Table ABC4 ABC5 593.0000 587.4800 ABC5 593.5000 587.6580 <= dup need to remove ABC5... (4 Replies)
Discussion started by: petersf
4 Replies

4. Shell Programming and Scripting

Count certain lines

Hi! I have a file that looks like this: AAG ---------------------------------------------------------------------- Number of residues in the repeat = 3 AGA ---------------------------------------------------------------------- Number of residues in the repeat = 3 AGG ... (2 Replies)
Discussion started by: vanesa1230
2 Replies

5. Shell Programming and Scripting

Extract section of file based on word in section

I have a list of Servers in no particular order as follows: virtualMachines="IIBSBS IIBVICDMS01 IIBVICMA01"And I am generating some output from a pre-existing script that gives me the following (this is a sample output selection). 9/17/2010 8:00:05 PM: Normal backup using VDRBACKUPS... (2 Replies)
Discussion started by: jelloir
2 Replies

6. Shell Programming and Scripting

How can i comment out a section between two particular lines

I want to find out which files under /etc have the the following section: and then i would like to comment out the above section in all the files. Please help. (3 Replies)
Discussion started by: proactiveaditya
3 Replies

7. Shell Programming and Scripting

using awk to get specific section of lines in logs

i have a log file that has the date and time that looks like this: Wed Jun 28 15:46:21 2012 test failed tailed passed passed not error panic what we want to focus on is the first 5 columns because they contain the date and time. the date and time can be anywhere on the line. in this... (6 Replies)
Discussion started by: SkySmart
6 Replies

8. Shell Programming and Scripting

split continues lines to separated section with conditions

Hello; i have a file contains N continues records. i want to split these lines to some separate sections with each lines of a section has the desired condition compared to other sections input: AZR ? ? ? Pn 37.202 48.82 1136119044 1136119009 SHB ? ? ? Pn 37.802 48.02 1136119047 1136119008... (4 Replies)
Discussion started by: saeed.soltani
4 Replies

9. Shell Programming and Scripting

Adding a lines to specific section of the file.

Hello, I have to a add 2 lines to /etc/sudoers file under this section below, can someone please suggest script to add these two lines when execute this remotely on to a multiple servers. before ## Allow root to run any commands anywhere root ALL=(ALL) ALL After ## Allow root... (2 Replies)
Discussion started by: bobby320
2 Replies

10. Shell Programming and Scripting

Count lines

Hello, I have a file with two columns like the following FILE1: chr1 61042 chr1 61153 chr1 61446 chr1 61457 chr1 61621 chr10 61646 chr10 61914 chr10 62024 chr10 62782 Alos, I have another file FILE2: (13 Replies)
Discussion started by: rkk
13 Replies
curs_scroll(3)						     Library Functions Manual						    curs_scroll(3)

NAME
curs_scroll, scroll, scrl, wscrl - Scroll a Curses window SYNOPSIS
#include <curses.h> int scroll( WINDOW *win ); int scrl( int n ); int wscrl( WINDOW *win, int n ); LIBRARY
Curses Library (libcurses) STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: scrl, wscrl, scroll: XCURSES4.2 Refer to the standards(5) reference page for more information about industry standards and associated tags. DESCRIPTION
The scroll routine scrolls the window up one line. This involves moving the lines in the window data structure. As an optimization, if the scrolling region of the window is the entire screen, the physical screen is scrolled at the same time. The scrl and wscrl routines, for positive n, scroll the current or specified window up n lines (line i+n becomes line i); otherwise, these routines scroll the window down n lines. This operation involves moving the lines in the window character-image structure. The routines do not change the current cursor position. For the scroll, scrl, and wscrl functions to work, the scrollok option must be enabled. NOTES
The header file <curses.h> automatically includes the header file <stdio.h>. Note that scrl may be a macro. RETURN VALUES
All routines return the integer ERR upon failure and OK upon successful completion. SEE ALSO
Functions: curses(3), curs_outopts(3) Others: standards(5) curs_scroll(3)
All times are GMT -4. The time now is 03:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy