2 sed snippets

Strip characters from a string or file with 'sed'

$ echo "A1B2C3" | sed 's/[A-Z]//g'
123
Tagged linux, sed, tool and one-liner.

 

Skip the first N lines in file

using tail

To skip the first line of a file (and start piping data at the second line):

tail -n +2 <FILENAME>

More generally:

tail -n +M <FILENAME>

where M is the number of the first line you want to see (i.e., the number of lines to skip plus one).

using sed

To skip the first line of a file (and start piping data at the second line):

sed 1d <FILENAME>

More generally:

sed A,Bd <FILENAME>

when you want to exclude lines A through B from the output.

Tagged linux, sed and tool.

 

This page was generated at 4:16 PM on 26 Feb 2018.
Copyright © 1999 - 2018 Rodney Waldhoff.