how to fetch part of a line and display

Input of data:

Student: Hari Roll No: 24777 Phone No: 122334 Student: Sudha Roll No: 247911 Phone No: 34552111 Student: Lata Roll No: 247790 Phone No: 7675656554

Student: Kutty Roll No: 24677 Phone No: 12442334 Student: Sudhar Roll No: 247411 Phone No: 3455244111

Output of data:

Student: Hari Roll No: 24777 Phone No: 122334

Student: Sudha Roll No: 247911 Phone No: 34552111

Student: Lata Roll No: 247790 Phone No: 7675656554

Student: Kutty Roll No: 24677 Phone No: 12442334
Student: Sudhar Roll No: 247411 Phone No: 3455244111

I want to dispaly in proper order as the output. how do i fetch particular position in a line and display in next line

try this

sed 's/Student:/\n&/g' infile

I got the output with "n" prefix with every start of line

nStudent: Hari Roll No: 24777 Phone No: 122334 nStudent: Sudha Roll No: 247911 Phone No: 34552111 nStudent: Lata Roll No: 247790 Phone No: 7675656554
nStudent: Kutty Roll No: 24677 Phone No: 12442334 nStudent: Sudhar Roll No: 247411 Phone No: 3455244111

hi rampriya.s
try this. ( after the backslash press return and go to a sub-line and go-on)

# sed 's/Student:/\
&/g' file

regards
ygemici

Hi ygemici,

It worked now :slight_smile:

Thanks a lot!!