This is my input file with extra information in the HEADER and leading & trailing SPACES between PIPE delimiter.
02/04/2010 Dynamic List Display 1
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
| FIST_NAME|LAST_NAME|ADDRESS |
--------------------------------------------------------------------------------------
| Rajesh |Verma |10/27/2004|
| James |David Jr |10/08/2009|
--------------------------------------------------------------------------------------
How to make output file like this, please help with UNIX script
FIST_NAME|LAST_NAME|ADDRESS|
Rajesh|Verma|164 N Tutor Ln, Chicago-IL|
James|David Jr|529 Carlton Arms Dr, Chicago-IL|
Thanks
srimitta
it's funny
02/04/2010 Dynamic List Display 1
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
| FIST_NAME|LAST_NAME|ADDRESS |
--------------------------------------------------------------------------------------
| Rajesh |Verma |10/27/2004|
| James |David Jr |10/08/2009|
--------------------------------------------------------------------------------------
How to make output file like this, please help with UNIX script
FIST_NAME|LAST_NAME|ADDRESS|
Rajesh|Verma|164 N Tutor Ln, Chicago-IL|
James|David Jr|529 Carlton Arms Dr, Chicago-IL|
What's from the address???
EAGL
March 13, 2010, 4:07pm
3
awk -F\| '{for(i=1;i<=NF;i++) gsub("^[ \t]*|[ \t]*$","",$i)}1' OFS=\| FILE
Hi, srimitta:
$ cat data
02/04/2010 Dynamic List Display 1
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
| FIST_NAME|LAST_NAME|ADDRESS |
--------------------------------------------------------------------------------------
| Rajesh |Verma |10/27/2004|
| James |David Jr |10/08/2009|
--------------------------------------------------------------------------------------
$ sed -n '/^| */{s///;s/ *| */|/g;p;}' data
FIST_NAME|LAST_NAME|ADDRESS|
Rajesh|Verma|10/27/2004|
James|David Jr|10/08/2009|
Regards,
Alister
john1212, Address was copy / paste mistake.
Thanks Alister worked like charm.
Regards
srimitta
Using Perl:
$
$ cat f0
02/04/2010 Dynamic List Display 1
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
| FIST_NAME|LAST_NAME|ADDRESS |
--------------------------------------------------------------------------------------
| Rajesh |Verma |10/27/2004|
| James |David Jr |10/08/2009|
--------------------------------------------------------------------------------------
$
$ perl -lne 's/\s*\|\s*/\|/g && print' f0
|FIST_NAME|LAST_NAME|ADDRESS|
|Rajesh|Verma|10/27/2004|
|James|David Jr|10/08/2009|
$
$
tyler_durden
Another straight awk solution.
awk -F"|" '/^\|/ { OFS="\|"; gsub(/ /,"",$0); print $2,$3,$4,$5; }' file