![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Enterprise Unix Roundup: The Ghost of Unix Future - Server Watch | iBot | UNIX and Linux RSS News | 0 | 12-19-2007 12:20 PM |
| Running UNIX commands remotely in Windows box from Unix box – avoid entering password | D.kalpana | UNIX for Dummies Questions & Answers | 1 | 04-20-2007 06:24 AM |
| FTP script for sending a file from one unix directory to another unix server director | raja_1234 | Shell Programming and Scripting | 1 | 11-30-2006 07:57 AM |
| Unix Sco Open Server, Windows Computers Problem Access Unix Shared Files Help!!!!! | haggo | Filesystems, Disks and Memory | 2 | 08-23-2006 12:39 PM |
| Unix History Question: Why are filenames/dirnames case sentsitive in Unix? | deckard | UNIX for Dummies Questions & Answers | 3 | 03-26-2005 01:59 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Unix
I have a data in a file called data1.dat like this:
70815|1418|V|F70816|1418|V|M 70817|1418|V|M70818|1418|V|F 70819|1418|V|M I want the output like this: 70815|1418|V|F 70816|1418|V|M 70817|1418|V|M 70818|1418|V|F 70819|1418|V|M Thanks in advance |
|
||||
|
Quote:
Code:
awk -F'|' '{print $1 "|" $2 "|" $3 "|" substr($4,0,1) "\n" substr($4,2) "|" $5 "|" $6 "|" $7}' data1.dat | grep -v '|||'
will work. The grep at the end handles any lines like the last line in the sample in which there are one instead of two records. |
![]() |
| Bookmarks |
| Tags |
| awk substr |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|