Sponsored Content
Top Forums Shell Programming and Scripting Extracting lines after nth LINE from an output Post 302627671 by haczyk on Saturday 21st of April 2012 06:55:05 AM
Old 04-21-2012
Code:
# awk ' $1 ~ /^[0-9]/' file
 1      32.3kB  65.5GB  65.5GB  primary  ext3         boot
 2      65.5GB  67.7GB  2147MB  primary  linux-swap
 3      67.7GB  500GB   432GB   primary  ext3
#

Code:
# cat file
Model: ATA WDC WD5000AAKS-0 (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  65.5GB  65.5GB  primary  ext3         boot
 2      65.5GB  67.7GB  2147MB  primary  linux-swap
 3      67.7GB  500GB   432GB   primary  ext3

Information: Don't forget to update /etc/fstab, if necessary.
#

if output came from another command just pipe it to awk

Edit: or use grep:
Code:
# grep '^.[0-9]' file
 1      32.3kB  65.5GB  65.5GB  primary  ext3         boot
 2      65.5GB  67.7GB  2147MB  primary  linux-swap
 3      67.7GB  500GB   432GB   primary  ext3
#

I forgot about sed:

Code:
$ sed -n '/^.[0-9]/p' file
 1      32.3kB  65.5GB  65.5GB  primary  ext3         boot
 2      65.5GB  67.7GB  2147MB  primary  linux-swap
 3      67.7GB  500GB   432GB   primary  ext3
$

Kind regards,

Last edited by haczyk; 04-21-2012 at 08:32 AM.. Reason: Add grep && sed code
This User Gave Thanks to haczyk For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need output in different lines not in one single line

I am getting the coutput like this as show below in one single line, where as the command is executed is several lines and the output should also be requied in several lines, not in one single line. Anyone any idea? p4 opened -a | grep *locked* | awk '{ printf $8 }' >/tmp/aa $ cat... (1 Reply)
Discussion started by: csaha
1 Replies

2. Shell Programming and Scripting

using tr to put multiple lines of output into one line

Hi all, For a intro UNIX course I'm taking, I need to use the command "tr" to display a file on standard output without any newlines (all on one line). I assume I would start with "cat filename | tr" but don't know what to put after tr. Any ideas would be lovely! Thanks. (3 Replies)
Discussion started by: otes4
3 Replies

3. Shell Programming and Scripting

Logfile - extracting certain lines to concatenate into 1 line

I've got a log file from automatic diagnostic runs. The log file is appended to each time an automatic log is run. I'd like to just pull certain lines from each run in the log file, and concatenate them into 1 comma delimited line (for export into excel or an html table). Each diagnostic run... (3 Replies)
Discussion started by: BecTech
3 Replies

4. Shell Programming and Scripting

Extracting line matching a phrase and then the next lines after it

Hi all, I was wondering if someone could tell me a way to extract from a file lines where you search for a phrase and then also extract the next X lines after it (i.e. take a block of text from the file)? Example { id=123 time=10:00:00 date=12/12/09 { ........ ... (6 Replies)
Discussion started by: muay_tb
6 Replies

5. Shell Programming and Scripting

extract nth line of all files and print in output file on separate lines.

Hello UNIX experts, I have 124 text files in a directory. I want to extract the 45678th line of all the files sequentialy by file names. The extracted lines should be printed in the output file on seperate lines. e.g. The input Files are one.txt, two.txt, three.txt, four.txt The cat of four... (1 Reply)
Discussion started by: yogeshkumkar
1 Replies

6. Shell Programming and Scripting

How to output all lines following Nth occurrence of string

Greetings experts. Searched the forums (perhaps not hard enough?) - Am searching for a method to capture all output from a log file following the nth occurrence of a known string. Background: Using bash, I want to monitor my Oracle DB alert log file. The script will count the total # of... (2 Replies)
Discussion started by: cjtravis
2 Replies

7. Shell Programming and Scripting

Calculating average for every Nth line in the Nth column

Is there an awk script that can easily perform the following operation? I have a data file that is in the format of 1944-12,5.6 1945-01,9.8 1945-02,6.7 1945-03,9.3 1945-04,5.9 1945-05,0.7 1945-06,0.0 1945-07,0.0 1945-08,0.0 1945-09,0.0 1945-10,0.2 1945-11,10.5 1945-12,22.3... (3 Replies)
Discussion started by: ncwxpanther
3 Replies

8. UNIX for Dummies Questions & Answers

Extracting the two lines where the first line is matched

Hi, If I have a file of something like @hg19_gold_AL122127.6-131160 GCTTCATCATGCATGGATAGGCTGGCGCCTTTCCTGAGGCCATATGCCGATGGATATG @hg19_gold_AL122127.6-131159 CTTTAATATTTCCGCCACCATCCTGAGTGAATCCCAGCAAGGACAGTCTTTGGGGATT @hg19_gold_AL122127.6-131158... (4 Replies)
Discussion started by: jyu429
4 Replies

9. Shell Programming and Scripting

Redirecting output from Nth line

Dear All, I have a shell script which output like some thing below 1.2.3.4 1.2.3.5 1.2.3.6 ------ Start of CSV ------- id ,number ,name ,location 1,101,asp,xyz 2,102,dsp,ert Now i need to redirect this output to csv file but from particular line number. i mean, first i need to skip... (5 Replies)
Discussion started by: onenessboy
5 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
XmTextFieldCut(3X)														XmTextFieldCut(3X)

NAME
XmTextFieldCut - A TextField function that copies the primary selection to the clipboard and deletes the selected text SYNOPSIS
#include <Xm/TextF.h> Boolean XmTextFieldCut (widget, time) Widget widget; Time time; DESCRIPTION
XmTextFieldCut copies the primary selected text to the clipboard and then deletes the primary selected text. This routine calls the wid- get's XmNvalueChangedCallback and verification callbacks, either XmNmodifyVerifyCallback or XmNmodifyVerifyCallbackWcs, or both. If both verification callback lists are registered, the procedures of the XmNmodifyVerifyCallback list are executed first and the resulting data is passed to the XmNmodifyVerifyCallbackWcs callbacks. Specifies the TextField widget ID. Specifies the time at which the selection value is to be modified. This should be the time of the event which triggered this request. For a complete definition of TextField and its associated resources, see XmTextField(3X). RETURN VALUE
This function returns False if the primary selection is NULL, if the widget doesn't own the primary selection, or if the function is unable to gain ownership of the clipboard selection. Otherwise, it returns True. SEE ALSO
XmTextField(3X) XmTextFieldCut(3X)
All times are GMT -4. The time now is 03:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy