will only show every 3rd line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting will only show every 3rd line
# 1  
Old 08-03-2010
will only show every 3rd line

Hi, how will i show every 3rd line of the file.
Ex.
Code:
line 1

line 2
line 3
line 4
line 5


line 6
line 7

Output:
Code:
line 2
line 5
line 6

tyhanks

---------- Post updated at 03:39 AM ---------- Previous update was at 03:37 AM ----------

Code:
vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 3  0    248 3500056 444596 11659336    0    0     6    47    0     2  4  3 93  0
 
sar 
Linux 2.6.9-67.ELsmp (eira4_dr) 	08/03/10

00:00:01          CPU     %user     %nice   %system   %iowait     %idle
00:00:02          all     11.75      0.00      7.25      0.00     81.00
00:00:03          all      0.75      0.00      0.25      0.00     99.00
00:00:04          all      0.00      0.00      0.00      0.00    100.00
00:00:05          all      0.25      0.00      0.25      0.00     99.50
00:00:06          all      0.00      0.00      0.00      0.25     99.75
Average:          all      2.55      0.00      1.55      0.05     95.85
Tue Aug  3 00:05:01 PHT 2010
 
vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
 1  0    248 3499032 444596 11659404    0    0     6    47    0     2  4  3 93  0
 
sar 
Linux 2.6.9-67.ELsmp (eira4_dr) 	08/03/10

00:05:01          CPU     %user     %nice   %system   %iowait     %idle
00:05:02          all      7.71      0.00      1.00      0.25     91.04
00:05:03          all      0.00      0.00      0.00      0.00    100.00
00:05:04          all      0.50      0.00      0.50      0.00     99.00
00:05:05          all      0.25      0.00      0.50      0.00     99.25
00:05:06          all      5.01      0.00      2.01      0.00     92.98
Average:          all      2.70      0.00      0.80      0.05     96.45
Tue Aug  3 00:10:01 PHT 2010



---------- Post updated at 03:40 AM ---------- Previous update was at 03:39 AM ----------

on my sample file i just want to get the data under vmstat under free with bold.

Last edited by Scott; 08-03-2010 at 06:40 AM.. Reason: Please use code tags
# 2  
Old 08-03-2010
Something like this?
Code:
awk '/procs --/{getline;getline;print $4}'  file

# 3  
Old 08-03-2010
dude you are genius... anyway you can use that for monitoring your free memory in vmstat and for cpu util , you could use that..thanks alot

Code:
grep -i ave|  awk '!( NR  % 12 ) {$0 = $0"\n"} 1'


Last edited by Scott; 08-03-2010 at 06:41 AM.. Reason: Code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep: show only first match per line?

Hi, can I make grep stop after finding the first occurrence of a regex in a line? Given: file with various regex patterns file to be grep'ed Sadly some of the regex patterns cannot be limited any further, so grep -Eiof patterns.txt file.txt (GNU grep 2.20) will give me possibly n hits... (4 Replies)
Discussion started by: stresing
4 Replies

2. Shell Programming and Scripting

Need to show highest version line from the list

Hi All, Need help here, can you tell me the syntax to line grep the highest file version? 0 04-05-2016 08:00 lib/SBSSchemaProject.jar/schemas/ 0 04-05-2016 08:00 lib/SBSSchemaProject.jar/schemas/airprice/ 0 04-05-2016 08:00 ... (2 Replies)
Discussion started by: 100rin
2 Replies

3. Shell Programming and Scripting

Using sed to show even numbers and the line

Hello, I have an assignment that requires us to use sed only. The first part of the assignment says to use a sed script to print only the even lines, but if it is print, the number of that lines needs to be printed before the text. ex: 2 line 2 text 4 line 4 text 6 line 6 text ... (3 Replies)
Discussion started by: stevent518
3 Replies

4. Shell Programming and Scripting

awk help about show all the line beside the changed line

awk '/abc/{print $2}' This will show the line contains abc and only show the "two filed" But I want to the line contains "abc" will only show $2, other line still show. and I want to know awk's way about not only show the line besides changed line Thanks (2 Replies)
Discussion started by: yanglei_fage
2 Replies

5. UNIX for Dummies Questions & Answers

Show the entire line using ps

Using the vanilla ps -ef I noticed that the CMD (or command) line gets cut off after 90 characters UID PID PPID C STIME TTY TIME CMD root 6020 3822 0 Jun 19 ? 0:01 ./webservd-wdog -r /export/opt/sows/61sp4 -d /export/opt/sows/61sp4/https-logse Googling... (4 Replies)
Discussion started by: SixSigma1978
4 Replies

6. UNIX for Dummies Questions & Answers

how to show it on separate line

# echo $PATH /home/user01/bin:/usr/local/bin:/usr/bin:/bin:/usr/ccs/bin:/usr/ucb:/dist/perl5/bin:/dist/fsf/bin:.:/usr/dt/bin:/etc/dt/tbin:/usr/openwin/bin how to show the PATH in separate line, ie: /home/user01/bin /usr/local/bin /usr/bin:/bin /usr/ccs/bin /usr/ucb etc...... (2 Replies)
Discussion started by: userking
2 Replies

7. Shell Programming and Scripting

sed remove last 10 characters of a line start from 3rd line

hello experts, I need a sed command that remove last 10 characters of a line start from 3rd line. any suggestions? Thanks you (7 Replies)
Discussion started by: minifish
7 Replies

8. Shell Programming and Scripting

How to quickly show Nth line from the file

Hi all, How can I quickly show Nth line from the huge file(at least more than 15GB)? I used the following script but seems slower. See 2717298 th line. head -2717298 data0802.dat | tail -1 Thank you very much (4 Replies)
Discussion started by: mr_bold
4 Replies

9. UNIX for Dummies Questions & Answers

Email to show only summary line

Hi everyone, can you suggest a way fro me to set something up so that i can start mail or mailx and have only the summary line of each email displayed, 24 lines (emails) per page and keep on navigating down throught the summary lines a full page at a time? My users have hundreds of emails ....... (0 Replies)
Discussion started by: gio001
0 Replies

10. UNIX for Dummies Questions & Answers

Making Emacs to show line number

Hi all How can I make Emacs to show the line numbers at the left or right as a default. This might help me to quickly jump to a given line. Thanks SS (9 Replies)
Discussion started by: saurya_s
9 Replies
Login or Register to Ask a Question