![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can i truncate filenmes? | Calum | UNIX for Dummies Questions & Answers | 11 | 07-30-2008 03:30 PM |
| Truncate Log files | anonymous1 | Shell Programming and Scripting | 1 | 10-21-2007 04:05 PM |
| Truncate File contain | rinku | Shell Programming and Scripting | 2 | 05-30-2007 03:43 AM |
| truncate wtmp | rocker40 | UNIX for Dummies Questions & Answers | 1 | 11-04-2004 02:57 PM |
| Truncate what is It? | rocker40 | UNIX for Dummies Questions & Answers | 2 | 10-11-2003 04:40 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a file in which I need to truncate 15th field to have only one character
like Put --> P and if i have no value in 15th field, it should be "O" (Other) would really appreciate the reponses, thnx in advance |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Here is a pointer .
It would be better if you could post a sample input and output if this is not what you are looking for Code:
cat 3 start|end|first another||quick Code:
awk -F"|" 'BEGIN{OFS="|"} { if ( length($2) ) { $2 = substr($2, 0, 1) } else { $2 = "O" } print }' 3
start|e|first
another|O|quick
Last edited by matrixmadhan; 08-14-2007 at 10:51 AM. Reason: better output |
|
#3
|
|||
|
|||
|
Thanks mate, works pretty well that's exactly wat I was looking for
|
|||
| Google The UNIX and Linux Forums |