Sponsored Content
Full Discussion: using sed to remove lines
Top Forums Shell Programming and Scripting using sed to remove lines Post 302442762 by Ikon on Thursday 5th of August 2010 11:15:23 AM
Old 08-05-2010
Worked on my HP-UX box, but I dont have a file for it to read.

Code:
#   sar -R -d 1 5

HP-UX MyServerName B.11.31 U ia64    08/05/10

08:13:46   device   %busy   avque     r/s     w/s  blks/s  avwait  avserv
08:13:47    disk3    1.00    0.50       0       1      16    0.00    8.66
08:13:48    disk3   13.00    0.50      30       0     480    0.00    4.34
08:13:49  c3t15d0    0.99    0.50       0       2      32    0.00    0.90
            disk3   56.44   67.69       1     143    2295  234.33   28.81
08:13:50    disk3   39.00    3.63       0      76    1118  119.57   38.54
           disk10    1.00    0.50       0       2      18    0.00    0.84
08:13:51

Average     disk3   21.96   41.63       6      44     785  170.89   28.75
Average   c3t15d0    0.20    0.50       0       0       6    0.00    0.90
Average    disk10    0.20    0.50       0       0       4    0.00    0.84

#   sar -R -d 1 5 | sed '2d'


08:14:09   device   %busy   avque     r/s     w/s  blks/s  avwait  avserv
08:14:10    disk3    3.92    0.50       8       1     204    0.00    4.50
08:14:11
08:14:12    disk3    1.00    0.50       0       2      36    0.00    7.92
08:14:13
08:14:14

Average     disk3    1.00    0.50       2       1      49    0.00    5.12

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed or Awk to remove specific lines

I have searched the forum for this - forgive me if I missed a previous post. I have the following file: blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah alter table "informix".esc_acct add constraint (foreign key (fi_id) references "informix".fi ... (5 Replies)
Discussion started by: Shoeless_Mike
5 Replies

2. Shell Programming and Scripting

Using sed to remove lines where field is empty

I was just looking at this post: https://www.unix.com/shell-programming-scripting/22893-delete-multiple-empty-lines.html. and I am looking to achieve the same with sed. So the idea is to delete lines from a file where a certain field has no value. Inputfile: EMID MMDDYY HOURS JOB EMNAME 0241... (4 Replies)
Discussion started by: figaro
4 Replies

3. Shell Programming and Scripting

How to remove lines before and after with awk / sed ?

Hi guys, I need to remove the pattern (ID=180), one line before and four lines after. Thanks. (5 Replies)
Discussion started by: ashimada
5 Replies

4. Shell Programming and Scripting

What's the command to remove empty lines with sed?

3 10 20 10 100 100 10000 Output: 3 10 20 10 100 100 10000 ---------- Post updated at 07:59 AM ---------- Previous update was at 07:56 AM ---------- sed '/^$/d' file doesn't work. (8 Replies)
Discussion started by: cola
8 Replies

5. Shell Programming and Scripting

SED to remove a line above and lines below.

:confused:Hi All, I need help on removing lines in a text file. Sample file : When there is a match ip for IPAddress in my `cat ip.out`, proceed delete line above until string "Comp" is found. Thank you very much. ---------- Post updated at 12:56 AM ---------- Previous update was... (4 Replies)
Discussion started by: chiewming
4 Replies

6. Shell Programming and Scripting

grep/sed to remove lines in file

Hi, I have a file with values, file1: BELL-1180-1180-81|577:1017| BELL-1180-1180-81|jm10i-auto-stub1/577:102| BELL-1180-1180-81|jm10i-auto-stub1/577:101| BELL-1180-1180-81|jm10i-auto-stub1/577:1700| BELL-1180-1180-81|jm10i-auto-stub1/577:1699| I need to remove the lines which has... (9 Replies)
Discussion started by: giri_luck
9 Replies

7. Shell Programming and Scripting

Remove a range of lines from a file using sed

Hi I am having some issue editing a file in sed. What I want to do is, in a loop pass a variable to a sed command. Sed should then search a file for a line that matches that variable, then remove all lines below until it reaches a line starting with a constant. I have managed to write a... (14 Replies)
Discussion started by: Andy82
14 Replies

8. Shell Programming and Scripting

Locate and remove lines with sed

Gents, I would like to remove some lines from a big file ( file2). The objetive is to remove all the lines in file2 containing a certain string which are in file data2delete.. file data2delete contens: 2573.0 7260.01 2893.0 7255.01 2903.0 7245.01 2897.0 7255.01 2561.0 7255.01... (6 Replies)
Discussion started by: jiam912
6 Replies

9. UNIX for Dummies Questions & Answers

How to remove certain lines using sed?

Hi I have the following kind of line sin my file . print ' this is first'. print ' this is firs and next ' ' line continuous '. -- this is entire print line. print ' this is first and next ' ' line continuous and' 'still there now over'. -- this 3lines together a single print line. ... (5 Replies)
Discussion started by: Sivajee
5 Replies

10. Shell Programming and Scripting

How to remove certain lines using sed?

Hi, I am new to unix and i started some scripting recently. Please go through the following script i wrote. #!/bin/sh file='path../tfile' file1='path../tfile1' rmfile='path../test2' C1=1 C2=1 exec 3< $file1 while read LINE1; do read LINE2 <&3 a=$LINE1 b=`expr $LINE2 - 1` ... (1 Reply)
Discussion started by: Subbu123
1 Replies
sar(1M) 																   sar(1M)

NAME
sar - system activity reporter SYNOPSIS
psetid] file] t [n] psetid] time] time] sec] file] DESCRIPTION
In the first form above, samples cumulative activity counters in the operating system at n intervals of t seconds. If the option is speci- fied, it saves the samples in file in binary format. The default value of n is 1. In the second form, with no sampling interval specified, extracts data from a previously recorded file, either the one specified by option or, by default, the standard system activity daily data file for the current day dd. The starting and ending times of the report can be bounded via the and time arguments of the form hh[:mm[:ss]]. The option selects records at sec-second intervals. Otherwise, all intervals found in the data file are reported. Options Subsets of data to be printed are specified by options: Report use of file access system routines: Number of file system calls per second. Number of file system (pathname translation) calls per second. Number of file system blocks read per second doing directory lookup. Report all data. Equivalent to Report buffer activity: Number of physical reads per second from the disk (or other block devices) to the buffer cache. Number of physical writes per second from the buffer cache to the disk (or other block device). Number of reads per second from buffer cache. Number of writes per second to buffer cache. Buffer cache hit ratio for read requests, for example, 1 - bread/lread. Buffer cache hit ratio for write requests, for example, 1 - bwrit/lwrit. Number of reads per second from character device using the (raw I/O) mechanism. Number of writes per second to character device using the (raw I/O) mechanism. Report system calls: Number of system calls of all types per second. Number of and/or system calls per second. Number of and/or system calls per second. Number of and/or system calls per second. Number of system calls per second. Number of characters transferred by read system calls block devices only) per second. Number of characters transferred by write system calls (block devices only) per second. Report activity for each block device, for example, disk or tape drive. One line is printed for each device that had activity during the last interval. If no devices were active, a blank line is printed. Each line contains the following data: Logical name of the device and its corresponding instance. Devices are categorized into the following device types: disk3 - SCSI and NIO FL disks sdisk - SCSI disks. Portion of time device was busy servicing a request. Average number of requests outstanding for the device. Number of data transfers per second (read and writes) from and to the device. Number of reads per second from the device. This information is available only when used with the option. Number of writes per second to the device. This information is available only when used with the option. Number of bytes transferred (in 512-byte units) from and to the device. Average time (in milliseconds) that transfer requests waited idly on queue for the device. Average time (in milliseconds) to service each transfer request (includes seek, rotational latency, and data transfer times) for the device. Refer to the section for information about legacy LUN. Uses file as the data source for Default is the current daily data file Report activity for each HBA device. One line is printed for each HBA device that had activity during the last interval. If no devices were active, a blank line is printed. Each line contains the following data: Logical name of the HBA device and its corresponding instance. Portion of time device was busy servicing a request. Number of bytes transferred (in MBs) from and to the device. Number of data transfers per second (read and writes) from and to the device. Number of reads per second from the device. Number of writes per second to the device. Number of bytes read (in MBs) from the device. Number of bytes written (in MBs) to the device. Average number of requests outstanding for the device. Average time (in milliseconds) that transfer requests waited idly on queue for the device. Average time (in milliseconds) to service each transfer request for the device. Report activity for each active lunpath. One line is printed for each lunpath that had activity during the last interval. If no lunpath were active, a blank line is printed. NOTE: The lunpaths are not displayed in any specific order and it is not guaranteed that the current order will be maintained in future releases. Each line contains the following data: symbolic name of the lunpath of the form: diskm_lunpathn, where m and n are the instance numbers of LUN and lunpath respectively. These instance numbers are displayed by using option for the LUN and lunpath entries. For more information on LUN and lunpath hard- ware path, refer to intro(7). Portion of time lunpath was busy servicing a request. Average number of requests outstanding for the lunpath. Number of reads per second from the lunpath. Number of writes per second to the lunpath. Number of bytes transferred (in 512-byte units) from and to the LUN using this lunpath. Average time (in milliseconds) that transfer requests waited idly on queue for this lunpath. Average time (in milliseconds) to service each transfer request (includes seek, rotational latency, and data transfer times) for this lunpath. Report message and semaphore activities: Number of System V calls per second. Number of System V calls per second. Number of System V calls per second. This value will only be reported if the option is also explicitly specified. Report the per-processor data on a multi-processor system when used with and/or options. If the option is not used on a multi-processor system, the output format of the and options is the same as the uni-processor output format and the data reported is the average value of all the active processors. Saves the samples in binary format. Report the specified ProcessorSet (pset) information. This option should be used with the or option. Report ProcessorSet (pset) information, mapping to the processor in the system or the specified pset. This option can only be used with and or and options. It can also be combined with option to display information for a particular pset. If system is not pset configured, it will display a warning message. Report average queue length while occupied, and percent of time occupied. On a multi-processor machine, if the option is used together with the option, the per-CPU run queue as well as the average run queue of all the active processors are reported. If the option is not used, only the average run queue information of all the active processors is reported. In a multi-processor pset configured system, if the option is used with the option, then the pset column will be displayed before the cpu column: pset id (only on a multi-processor and pset configured system, used with and option). cpu number (only on a multi-processor system and used with the option). Average length of the run queue(s) of processes (in memory and runnable). The percentage of time the run queue(s) were occupied by processes (in memory and runnable). Average length of the swap queue of runnable processes (processes swapped out but ready to run). This column will not be displayed when option is used to display a particular ProcessorSet (pset) information in a pset configured system. The percentage of time the swap queue of runnable processes (processes swapped out but ready to run) was occupied. This column will not be displayed when option is used to display a particular ProcessorSet (pset) information in a pset configured system. This option is used with the option to report the number of reads and writes per second to the device. Refer to the description of the option for details. Report the number of System V calls per second. This option is valid only if the option is specified. Report activity for each tape device. One line is printed for each tape device that had activity during the last interval. If no devices were active, a blank line is printed. Each line contains the following data: Logical name of the tape device and its corresponding instance. Portion of time the device was busy servicing a request. Number of reads per second from the device. Number of writes per second to the device. Number of bytes read (in MBs) from the device. Number of bytes written (in MBs) to the device. Average time (in milliseconds) to service each transfer request (includes seek, rotational latency, and data transfer times) for the device. Report CPU utilization (the default); portion of time running in one of several modes. On a multi-processor system, if the option is used together with the option, per-CPU utilization as well as the average CPU utilization of all the active processors are reported. If the option is not used, only the average CPU utilization of all the active processors is reported. On a multi- processor ProcessorSet (pset) configured system, if the option is used together with the and options, the column for pset map- ping to processor will be displayed before the cpu column. pset id (only on a multi-processor pset configured system with the and option). cpu number (only on a multi-processor system with the option). user mode. system mode. idle with some process waiting for I/O (only block I/O, raw I/O, or VM pageins/swapins indicated). otherwise idle. Report status of text, process, inode and file tables: (Not Applicable). The current-size and maximum-size of the process table. The current-size and maximum-size of the inode table (inode cache). The current-size and maximum-size of the system file table. (Not Applicable). The number of times the process table overflowed (number of times the kernel could not find any available process table entries) between sample points. The number of times the inode table (inode cache) overflowed (number of times the kernel could not find any available inode table entries) between sample points. The number of times the system file table overflowed (number of times the kernel could not find any available file table entries) between sample points. Report system swapping and switching activity: Number of process swapins per second. Number of process swapouts per second. Number of 512-byte units transferred for swapins per second. Number of 512-byte units transferred for swapouts per second. Number of process context switches per second. Report tty device activity: Raw input characters per second. Input characters per second processed by Output characters per second. Receive incoming character interrupts per second. Transmit outgoing character interrupts per second. Modem interrupt rate (not supported; always 0). Report Memory File System (MemFS) data. will recognize the option when HP's optional product is installed on the system; it will display the number of MemFS blocks in memory (blkcnt) and the number of MemFS blocks in swap (swpcnt). The number of MemFS blocks is expressed in terms of 4 KB only. Note that the option does not record MemFS data into a file. However, if the and options are used together, then the data for all the options except the MemFS option is recorded into a file. You can then query this data. It is also not possible to use the option with the option. Using the option and the option together will not display the MemFS data. However, using the option with t and n will display the MemFS data. EXAMPLES
Watch CPU activity evolve for 5 seconds: Watch CPU activity evolve for 10 minutes and save data: If the product is installed, watch MemFS activity evolve for 10 minutes and save data; all data other than MemFS data is stored in file Review disk and tape activity from that period later: Review cpu utilization on a multi-processor system later: Watch lunpath activity evolve for 5 seconds: Watch tape activity evolve for 5 seconds: Watch HBAs activity evolve for 5 seconds: Watch disk reads and writes per second for 5 seconds: WARNINGS
Users of must not rely on the exact field widths and spacing of its output, as these will vary depending on the system, the release of HP- UX, and the data to be displayed. The output of is unpredictable if a corrupted or wrong data file is given as argument with the option. For devices that are opened and closed frequently (such as tapes), data might not be reported for the activity in the prior interval. The data might not be reported, because the device might be closed at the instant when data is collected. The recommendation for such devices is to use shorter intervals (t) of seconds. When multi-pathing is enabled and I/O is issued on a legacy LUN, may not report I/O that is redirected through other paths to the agile device. The behavior of the and scripts and the command remain unaltered with the product; these scripts and command do not record data reported by the option. FILES
daily data file, where dd is two digits representing the day of the month. SEE ALSO
ioscan(1M), sa1(1M), pstat(2), intro(7). STANDARDS CONFORMANCE
sar(1M)
All times are GMT -4. The time now is 04:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy