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
extlinux(1)						      General Commands Manual						       extlinux(1)

NAME
extlinux - install the SYSLINUX bootloader on a ext2/ext3 filesystem SYNOPSIS
extlinux [options] directory DESCRIPTION
EXTLINUX is a new syslinux derivative, which boots from a Linux ext2/ext3 filesystem. It works the same way as SYSLINUX, with a few slight modifications. It is intended to simplify first-time installation of Linux, and for creation of rescue and other special-purpose boot disks. The installer is designed to be run on a mounted directory. For example, if you have an ext2 or ext3 usb key mounted on /mnt, you can run the following command: extlinux --install /mnt OPTIONS
-H, --heads=# Force the number of heads. -i, --install Install over the current bootsector. -O, --clear-once Clear the boot-once command. -o, --once=command Execute a command once upon boot. -M, --menu-save=label Set the label to select as default on the next boot -r, --raid Fall back to the next device on boot failure. --reset-adv Reset auxiliary data. -S, --sectors=# Force the number of sectors per track. -U, --update Updates a previous EXTLINUX installation. -z, --zip Force zipdrive geometry (-H 64 -S 32). FILES
The extlinux configuration file needs to be named extlinux.conf and needs to be stored in the extlinux installation directory. For more information about the contents of extlinux.conf, see syslinux(1) manpage, section files. BUGS
I would appreciate hearing of any problems you have with SYSLINUX. I would also like to hear from you if you have successfully used SYS- LINUX, especially if you are using it for a distribution. If you are reporting problems, please include all possible information about your system and your BIOS; the vast majority of all problems reported turn out to be BIOS or hardware bugs, and I need as much information as possible in order to diagnose the problems. There is a mailing list for discussion among SYSLINUX users and for announcements of new and test versions. To join, send a message to majordomo@linux.kernel.org with the line: SEE ALSO
syslinux(1) SYSLINUX for ext2/ext3 filesystem 18 December 2007 extlinux(1)
All times are GMT -4. The time now is 06:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy