I have a file with this format:
two columns of numbers in the beginning and two columns of number in the end and one column in the middle which is the name but the name has a delimiter of space which mess things up.
Is there any kind of regex that I can take out the name column correctly. Is there anyway that i can use sed to replace (or remove) the space in that column so that I can take that out column out easily?
Example:
1 2 name 3 4
12 12 name1 name2 3 4
12 12 name1 name2 name3 name4 3 4
3 4 name 3 4
—
The output that I want to have is:
name
name1_name2
name1_name2_name3_name4
name
Thanks,
Amir,
One solution using awk is:
Here is the same thing using sed:
POSIX compliant for clarity: