Assume a text file that comprises alternating lines. Specifically, line 1 of each line pair starts with a "#", whereas the subsequent line of each line pair contains an alphanumeric string.
$ cat file
#Foo
1234567
#Bar
1234
#Baz
123456789
How do I automatically append the length of line 2 (as well as a keyword) to line 1 of each line pair? I believe that awk is the right choice for such an operation.
$ awk 'desired code' file
#Foo_Length7
1234567
#Bar_Length4
1234
#Baz_Length9
123456789
Here's my try, but I can't figure out what to substitute the length($0) with:
awk '{if ($1~/^#/) print $0"_Length"length($0); else print $0}' file