I have a file MDD.TXT with following records.file : MDD.TXT0|ABC|055309|20120929053309|11965150   0|ABC|061434|20120929063434|11155537  0|ABC|070228|20120929073228|11965150  0|ABC|082213|20120929583213|11965150  0|ABC|083950|20120929983950|11965150  0|ABC|084112|20120929083112|11965150Now I want to replace the second column with XYZ and want to add two column filename and success in all record. the desired output should be following:0|XYZ|055309|20120929053309|11965150|MDD.TXT|SUCCESS0|XYZ|061434|20120929063434|11155537|MDD.TXT|SUCCESS0|XYZ|070228|20120929073228|11965150|MDD.TXT|SUCCESS0|XYZ|082213|20120929583213|11965150|MDD.TXT|SUCCESS0|XYZ|083950|20120929983950|11965150|MDD.TXT|SUCCESS0|XYZ|084112|20120929083112|11965150|MDD.TXT|SUCCESS
how to change one column and add other columns in a row by awk
shell script;awk
You can try following awk:awk 'BEGIN { FS = OFS = | } { $2 = XYZ; $6 = ARGV[1]; $7 = SUCCESS;} 1' MDD.TXTor:awk 'BEGIN { FS = OFS = | } { $2 = XYZ; print $0 OFS ARGV[1] OFS SUCCESS; }' MDD.TXT