L
L
lem_prod2016-05-31 20:15:38
linux
lem_prod, 2016-05-31 20:15:38

How to output individual lines to the console from a file?

there is a file, for example, with the following content:
"Peter
Petrenko"
it is necessary that the output in the console be:
"First name: Petya
Surname: Petrenko"
if you just had to display separate lines, then
sed -n -e 1p -e 2p filename
how to change them first?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Burov, 2016-05-31
@BuriK666

It?
or
sed -e ':a' -e 'N' -e 's/\n/ /g'

A
abcd0x00, 2016-06-01
@abcd0x00

[[email protected] ~]$ echo -e "Петя\nПетренко"
Петя
Петренко
[[email protected] ~]$ echo -e "Петя\nПетренко" | sed '1s/^/Имя: /; 2s/^/Фамилия: /'
Имя: Петя
Фамилия: Петренко
[[email protected] ~]$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question