0
In the awk
piped to sed
below I am trying to format file by removing the odd xxxx_digits
and whitespace after, then move the even xxxx_digit
to the line above it and add a space between them. There may be multiple lines in file
but they are in the same format. The Filename_ID
line is the last line in the block and is unique to each. There will always be a newline seperating the blocks and that line FileName_ID
is not processed only printed. It is possible that there is noting above the FileName_ID
and if this happens then it is also printed as is.
file
00-0000-Lname-Fname-REPEAT
xxxx_0001 xxxx_0002
111111-yyyy
xxxx_0003 xxxx_0008
111111-yyyy-0
xxxx_0009 xxxx_0006
FileName_ID
FileName_ID
desired
xxxx_0002 00-0000-Lname-Fname-REPEAT
xxxx_0008 111111-yyyy
xxxx_0006 111111-yyyy-0
FileName_ID
FileName_ID
awk
awk 'NR%2{printf "%s ",$0;next;}1' file | sed 's/xxxx_[0-9][0-9][0-9][13579]//g'