Sponsored Content
Top Forums Shell Programming and Scripting Extract 10th line in the file Post 302424381 by devtakh on Tuesday 25th of May 2010 05:37:12 AM
Old 05-25-2010
Try this:

Code:
awk '/searchstring/{for(i=0;i<10;i++)print a[(i+NR)%10];print;for(i=0;i<10;i++){getline;print}}{a[NR%10]=$0}' filename


cheers,
Devaraj Takhellambam
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract a line from a file using the line number

I have a shell script and want to assign a value to a variable. The value is the line exctrated from a file using the line number. The line number it is not fix, and could change any time. I have tried sed, awk, head .. See my script # Get randome line number from the file #selectedline = `awk... (1 Reply)
Discussion started by: zambo
1 Replies

2. Shell Programming and Scripting

extract a line from a file using the line number

Hello, I am having trouble extracting a specific line from a file when the line number is known. My first attempt involved grep -n 'hi' (the word 'hi will always be there) to get the line number before the line that I actually want (line 4). Extra Notes: -I am working in a bash script. -The... (7 Replies)
Discussion started by: grandtheftander
7 Replies

3. Shell Programming and Scripting

extract line by line from file

hi dudes, I have a text file in the below format 1 s sanity /u02 2 r script1 /u02 3 s sanity /u02 Please tell me a script to read this file line by line, I wrote the below script , but it is printing only 1st line not printing rest... (7 Replies)
Discussion started by: shirdi
7 Replies

4. Shell Programming and Scripting

get the fifth line of a text file into a shell script and trim the line to extract a WORD

FOLKS , i have a text file that is generated automatically of an another korn shell script, i want to bring in the fifth line of the text file in to my korn shell script and look for a particular word in the line . Can you all share some thoughts on this one. thanks... Venu (3 Replies)
Discussion started by: venu
3 Replies

5. Shell Programming and Scripting

Cut file after 10th occurence

I have a file that I do a count on : cp $file data1 x=$(grep -c "Considerations:" data1)and I need to cut the file after the 10th occurrence of the word 'Considerations:' in $file (1 Reply)
Discussion started by: dba_frog
1 Replies

6. Shell Programming and Scripting

extract a line from a file by line number

Hi guys, does anyone know how to extract(grep) a line from the file, if I know the line number? Thanks a lot. (9 Replies)
Discussion started by: aoussenko
9 Replies

7. Shell Programming and Scripting

HELP: Shell Script to read a Log file line by line and extract Info based on KEYWORDS matching

I have a LOG file which looks like this Import started at: Mon Jul 23 02:13:01 EDT 2012 Initialization completed in 2.146 seconds. -------------------------------------------------------------------------------- -- Import summary for Import item: PolicyInformation... (8 Replies)
Discussion started by: biztank
8 Replies

8. Shell Programming and Scripting

Insert carriage return on the 10th char position of each line

Hi experts, Need your help on how to insert carriage return after the 10th char position of each line in a file and then add two blank spaces after the carriage return. Example: >cat test.txt testingline dummystring samplesample teststringline Expected output should be.. ... (2 Replies)
Discussion started by: brichigo
2 Replies

9. Shell Programming and Scripting

Perl to extract information from a file line by line

In the below perl code I am using tags within each line to extract certain information. The tags that are used are: STB >0.8 is STRAND BIAS otherwise GOOD FDP is the second number GO towards the end of the line is read into an array and the value returned is outputed, in the first line that... (1 Reply)
Discussion started by: cmccabe
1 Replies

10. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies
LED(4)							   BSD Kernel Interfaces Manual 						    LED(4)

NAME
led -- API for manipulating LED's, lamps and other annunciators SYNOPSIS
#include <dev/led/led.h> typedef void led_t(void *priv, int onoff); struct cdev * led_create_state(led_t *func, void *priv, char const *name, int state); struct cdev * led_create(led_t *func, void *priv, char const *name); void led_destroy(struct cdev *); DESCRIPTION
The led driver provides generic support for handling LEDs, lamps and other annunciators. The hardware driver must supply a function to turn the annunciator on and off and the device name of the annunciator relative to /dev/led/. The priv argument is passed back to this on/off function and can be used however the hardware driver sees fit. The lamp can be controlled by opening and writing ASCII strings to the /dev/led/bla device. In the following, we will use this special notation to indicate the resulting output of the annunciator: * The annunciator is on for 1/10th second. _ The annunciator is off for 1/10th second. State can be set directly, and since the change happens immediately, it is possible to flash the annunciator with very short periods and syn- chronize it with program events. It should be noted that there is a non-trivial overhead, so this may not be usable for benchmarking or mea- suring short intervals. 0 Turn the annunciator off immediately. 1 Turn the annunciator on immediately. Flashing can be set with a given period. The pattern continues endlessly. f _* f1 _* f2 __** f3 ___*** ... f9 _________********* Three high-level commands are available: d%d Numbers. Each digit is blinked out at 1/10th second, zero as ten pulses. Between digits a one second pause and after the last digit a two second pause after which the sequence is repeated. s%s String. This gives full control over the annunciator. Letters 'A' ... 'J' turn the annunciator on for from 1/10th to one full second. Letters 'a' ... 'j' turn the annunciator off for 1/10th to one full second. Letters 'u' and 'U' turn the annunciator off and on respectively when the next UTC second starts. Unless terminated with a '.', the sequence is immediately repeated. m%s Morse. '.' becomes '_*' '-' becomes '_***' ' ' becomes '__' ' ' becomes '____' The sequence is repeated after a one second pause. FILES
/dev/led/* EXAMPLES
A 'd12' flashes the lamp *__________*_*______________________________ A 'sAaAbBa' flashes *_*__**_ /usr/games/morse -l "Soekris rocks" > /dev/led/error SEE ALSO
morse(6) HISTORY
The led driver first appeared in FreeBSD 5.2. AUTHORS
This software was written by Poul-Henning Kamp <phk@FreeBSD.org>. This manual page was written by Sergey A. Osokin <osa@FreeBSD.org> and Poul-Henning Kamp <phk@FreeBSD.org>. BSD
April 24, 2007 BSD
All times are GMT -4. The time now is 05:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy