[[+content_image]]
T
T
Thomas Storm2015-07-08 11:37:54
bash
Thomas Storm, 2015-07-08 11:37:54

How to remove first and last lines using awk or sed?

There is a sql script that produces a list of users.

[[email protected] ~]$ sqlplus -s system/*** @show_users.sql

USERNAME
------------------------------
user1
user2
user3
user4

4 rows selected.

[[email protected] ~]$

Question: how to remove part of the output (username and --------) and number of received rows (rows selected) using sed or awk (or what other bash tools). At the output, you need to stupidly get a list of users (user1, 2, 3, etc.)

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
D
DevMan, 2015-07-08
@v_sadist

something like this:

sqlplus -s system/*** @show_users.sql | sed -n '1,/---/d;/\s/q;p'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question