Question: I have the following file (F1):

```
if a equals b
you
three aggbc four

```

I want the output to be:

```
if a equals b b b
you you you
three aggbc four four four

```

I run the following command:

```
sed -re 's/.*([^ ]+)[ |$]/\0 \1 \1/' F1

```

But it wont work.

The output I get is wrong:

```
if a equals  s sb
you
three aggbc  c cfour

```

I need it as a `sed` command.

Answer: 
```
sed -r 's/^(.* )?(.*)$/\1\2 \2 \2/' F1

```
If you are interesting to learn awk, here it is:

```
awk '{print $0 FS $NF FS $NF}' file

awk '{$NF=$NF FS $NF FS $NF}1' file 

```