Find the smallest block

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find the smallest block
# 1  
Old 10-22-2013
Find the smallest block


Here's my data -


Now I need to find the smallest block surrounded by aa & dd. Following is not helpful -

sed -n '/aa/,/dd/p' file

I need only -
# 2  
Old 10-22-2013
Using awk:

awk '
  CAP{block=block "\n" $0}
  /dd/{print substr(block,2); CAP=block=x}' infile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with keep the smallest record in file

Input file US Score 10 UK Ball 20 AS Score 50 AK Ball 10 PZ Ballon 50 PA Score 70 WT Data 10 . . Desired output file US Score 10 AK Ball 10 WT Data 10 . . (2 Replies)
Discussion started by: perl_beginner
2 Replies

2. Shell Programming and Scripting

How to write program that find winner who choose the smallest number. UNIX process?

In the game of “Unique”, multiple players privately choose an integer. They then reveal their choice. The winner is the player who chose the smallest unique number. The game is considered a draw if no unique integer was chosen. You would write a program that simulate such a game according to the... (1 Reply)
Discussion started by: dantesma
1 Replies

3. Shell Programming and Scripting

Find smallest between replicates ID

Hi All I need to find the smallest values between replicates id (column1) Input file: a name1 1200 a name2 800 b name1 100 b name2 150 b name3 4output: a name2 800 b name3 4 Do you have any suggestion? Thank you! (9 Replies)
Discussion started by: giuliangiuseppe
9 Replies

4. Shell Programming and Scripting

Find smallest & largest in every column

Dear All, I have input like this, J_15TEST_ASH05_33A22.13885.txt: $$ 1 MAKE SP1501 1 1 4 6101 7392 2 2442 2685 18 3201 4008 20 120 4158 J_15TEST_ASH05_33A22.13885.txt: $$ 1 MAKE SP1502 1 1 4 5125 6416 2 ... (4 Replies)
Discussion started by: attila
4 Replies

5. UNIX for Dummies Questions & Answers

Smallest UNIX operating system

Which is the smallest Unix operating system and how do I download it? edit by bakunin: corrected typo in the thread-title and removed the text formatting: we are able to read non-bold text either. (4 Replies)
Discussion started by: Nalcolmshally
4 Replies

6. Programming

Help with find highest and smallest number in a file with c

Input file: #data_1 AGDG #data_2 ADG #data_3 ASDDG DG #data_4 A Desired result: Highest 7 Slowest 1 code that I try but failed to archive my goal :( #include <stdio.h> (2 Replies)
Discussion started by: cpp_beginner
2 Replies

7. Shell Programming and Scripting

AWK (how) to get smallest/largest nr of ls -la

Hey, This is a long-shot however, I am stuck with the following problem: I have the output from ls -la, and I want to sort some of that data out by using AWK to filter it. ls -la | awk -f scriptname.awk Input: For example: drwxr-xr-x 3 user users 4096 2010-03-14 20:15 bin/... (5 Replies)
Discussion started by: abciscool
5 Replies

8. Programming

smallest resolution using gettimeofday() in C

Hello ... Can somebody help telling me how smallest clock resolution on ones sytem can be in obtained in C using gettimeofday() . Thankz in advance... (4 Replies)
Discussion started by: harsha10
4 Replies

9. UNIX for Dummies Questions & Answers

How to print largest and smallest number.

Hey. This is pretty easy stuff but I'm learning the basics of Unix at the moment so keep that in mind. I have to: 1) Write a C-shell script to monitor user activity on the server for 13 minutes. 2) Then print the smallest and largest number of users during these 13 minutes. I have this: 1)... (2 Replies)
Discussion started by: amp10388
2 Replies

10. Shell Programming and Scripting

checking the smallest and largest number

Hi All, My script is reading a log file line by line log file is like ; 19:40:22 :INFO Total time taken to Service External Request---115ms 19:40:25 DEBUG : Batch processed libdaemon.x86_64 0-0.10-5.el5 - u 19:40:22 INFO Total time taken to Service External Request---20ms 19:40:24... (4 Replies)
Discussion started by: subin_bala
4 Replies
Login or Register to Ask a Question