Um caminho:
awk '{$3=$3" | ";print "user | "$0;}' file
Eu tenho que formatar a saída do comando awk que obtém a entrada de um arquivo
Sample Input File
123 ABC 12 23 34 45 56 67 78 13
234 DEF 23 34 45 56 67 78 89
345 GHI 34 45 56 67 78 90 10 01 99
456 JKL 45 56 67 78 90 12 34
Required Output
user | 123 ABC 12 | 23 34 45 56 67 78 13
user | 234 DEF 23 | 34 45 56 67 78 89
user | 345 GHI 34 | 45 56 67 78 90 10 01 99
user | 456 JKL 45 | 56 67 78 90 12 34
Eu tentei o comando abaixo, que me deu algum erro
awk -v user=$user '{ printf user "|" $1" "$2" "$3 "|" "$1=$2=$3=""" $0;printf("\n"); }' sampleinputfile
Error Message
user | 123 ABC 12 | 23 34 45 56 67 78 13
user | 234 DEF 23 | 34 45 56 67 78 89
user | 345 GHI 34 | 45 56 67 78 90 10 01 99
user | 456 JKL 45 | 56 67 78 90 12 34
awk: (FILENAME=sampleinputfile FNR=4) fatal: not enough arguments to satisfy format string
'user | 456 JKL 45|$1=$2=$3=456 JKL 45 56 67 78 90 12 34
^ ran out for this one
Um caminho:
awk '{$3=$3" | ";print "user | "$0;}' file
Tags awk linux aix shell-script