I have a file with following content: $ cat -n w     1  Smith   John    12345   jsmith     2  Jones   Robert  23456   rjones     3  Green   Ralph   34567   rgreen     4  Brown   Fred    45678   fbrown     5  Orange  Mabel   56789   morangI want to get each line and then append at the end of that line the same text of that line.Example I want this output: $ cat -n w     1  Smith   John    12345   jsmith  Smith   John    12345   jsmith     2  Jones   Robert  23456   rjones  Jones   Robert  23456   rjones     3  Green   Ralph   34567   rgreen  Green   Ralph   34567   rgreen     4  Brown   Fred    45678   fbrown  Brown   Fred    45678   fbrown     5  Orange  Mabel   56789   morange Orange  Mabel   56789   morangeI looked into sed command with backreferencing however I can't get it to work$ sed 's/(.*)/\t\1/' widersed: -e expression #1, char 12: invalid reference \1 on `s' command's RHS
sed backreference: get each line and append it to end of line
sed;regular expression
sed use BRE by default, you need to escape \(...\) to capture the matching:LC_ALL=C sed 's/\(.*\)/\1\t\1/' <fileor using -E to enable ERE (which available in GNU sed and BSD sed, and will become standard soon), so you must not escape (...):LC_ALL=C sed -E 's/(.*)/\1\t\1/' <fileSetting locale to C help you match invalid unicode characters.But, it's better job for paste:paste file fileor awk:awk '{printf %s\t%s\n, $0, $0}' <file