Scripting awk or sed or shell

input

buff_1 abc satya_1
pvr_1
buff_2 def satya_1
pvr_1
buff_3 ghi satya_1
pvr_1
buff_4 jkl satya_1
pvr_1

required out put

buff_1 abc satya_1
pvr_1 abc satya_1
buff_2 def satya_1
pvr_1 def satya_1
buff_3 ghi satya_1
pvr_1 ghi satya_1
buff_4 jkl satya_1
pvr_1 jkl satya_1

Hi this is my input file format,
In second row column2 , column 3 values are blank.
if column 2 & column3 values are blank , then i need to insert above line column 2 column3 values .

hey can u post sample input file and the required output!!

use code tags

Try:

awk 'NF>1{s=$2 FS $3}NF==1{$0=$0 FS s}1' file
1 Like

Try:

awk ' NF == 3 { a=$1; b = $2; c=$3 ; readline}; { print $1, b, c }' INPUTFILE

droid

1 Like

hi can u send exact sysntax

awk '1;getline $1' infile 
1 Like

Nice! :slight_smile:

1 Like