Hi,
I have a pipe delimited file as below and I need to replace the 2nd column of each line with null values.
1|10/15/2011|fname1|lname1
2|10/15/2012|fname2|lname2
3|10/15/2013|fname3|lname3
Output file:
1||fname1|lname1
2||fname2|lname2
3||fname3|lname3
I tried this
awk -F"|" -v OFS="|" '{ $2=""}' filename.txt
Can anyone please help me with this urgent requirement?
Thanks in advance.
---------- Post updated at 10:36 AM ---------- Previous update was at 10:31 AM ----------
Was a syntax error. This worked.
awk -F"|" -v OFS="|" '$2 { $2=""} 1' filename.txt > newfilename.txt