Hi i am tring to move with this below formatted text
input:
NICK JEFF
NOAA A4:80:15
NOAA A4:80:17
NOOI D0:F2:0B BASE-TREE_IN-M_K
NICK STAN
NOAA C1:46:6B
NOOI D5:75:0C BASE-TREE_OUT_OUT
NICK INDEXER
NOOI D5:75:0C SEAT_25
NOAA C1:46:6B
NICK VUZER
NOAA A4:F2:CD
NOOI D0:F2:2D SEAT_42_FLIGHT
NOAA A4:F2:CD
NICK CAPTAIN
NOOI A4:82:8D
NOAA A4:82:8F
NOOI 40:63:07 SYS-BRAVO_X1
NOOI 40:62:DB SYS-BRAVO_X2
NOOI 40:62:B5 SYS-BRAVO_X3
NOOI D0:47:4A BASE-TREE_OUT_OUT
NOOI 51:30:45 NOBASE-INDEX_OUT_FIF
NOOI A4:82:8D
NOAA A4:82:8F
i tried this one but its copying me values wrongly
awk '{for (i=1; i<=1; i++) { print $i " " $1" "$2" "$3}}' input
expected output should be sorted out like below:
NICK JEFF NOAA A4:80:15 EMPTY
NICK JEFF NOAA A4:80:17 EMPTY
NICK JEFF NOOI D0:F2:0B BASE-TREE_IN-M_K
NICK STAN NOAA C1:46:6B EMPTY
NICK STAN NOOI D5:75:0C BASE-TREE_OUT_OUT
NICK INDEXER NOOI D5:75:0C SEAT_25
NICK INDEXER NOAA C1:46:6B EMPTY
NICK VUZER NOAA A4:F2:CD EMPTY
NICK VUZER NOOI D0:F2:2D SEAT_42_FLIGHT
NICK VUZER NOAA A4:F2:CD EMPTY
NICK CAPTAIN NOOI A4:82:8D EMPTY
NICK CAPTAIN NOAA A4:82:8F EMPTY
NICK CAPTAIN NOOI 40:63:07 SYS-BRAVO_X1
NICK CAPTAIN NOOI 40:62:DB SYS-BRAVO_X2
NICK CAPTAIN NOOI 40:62:B5 SYS-BRAVO_X3
NICK CAPTAIN NOOI D0:47:4A BASE-TREE_OUT_OUT
NICK CAPTAIN NOOI 51:30:45 NOBASE-INDEX_OUT_FIF
NICK CAPTAIN NOOI A4:82:8D EMPTY
NICK CAPTAIN NOAA A4:82:8F EMPTY
it means pattern is "nick" all the time and file reading direction of input file is from top to down and nickname like jeff stan etc.. is placed (copied) before it means its set as 1st and 2nd columns followed by previous columns from input. Text "EMPTY" is added to empty fields to preserve format/to have equal columns / fields numbers filled with values
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…