Computing.Net > Forums > Unix > how to get fixed width file in unix

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

how to get fixed width file in unix

Reply to Message Icon

Name: trichyselva
Date: March 2, 2007 at 00:54:19 Pacific
OS: xin xp
CPU/Ram: p4
Product: pentium
Comment:

i have a file in unix in which datas are like this

07 01 abc data entry Z3 data entry ASSISTANT Z3 39
08 01 POD peadiatrist Z4 POD PeDIATRY Z4 67
01 operator specialist 00 operator UNSPECIFIED A0 00
02 OLD NPA SPECIALTY 01 GP GENERAL PRACTICE C5 01

i want the datas to be tilde delimited as
07~01~abc~data entry~Z3~data entry ASSISTANT~Z3~39
~01~~operator specialist~00~operator UNSPECIFIED~A0~00

can anybody help me on this in writing code for this



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 2, 2007 at 09:50:50 Pacific
Reply:

I'm interpreting that you want a carriage return at the first word that is all capital letters:

sed 's/ /~/g' d.file|
awk ' BEGIN { FS = "~"; OFS = "~" }
{
ff=0
for (i=1; i<NF; i++)
if($i ~ /^[A-Z]+$/ && ff==0)
{
$i="\n"$i
ff=1
}
printf("%s\n", $0)
} '


0

Response Number 2
Name: ghostdog
Date: March 3, 2007 at 21:35:56 Pacific
Reply:

take note that OP doesn't want all spaces converted to ~


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: how to get fixed width file in unix

Where to find c head files in unix system? No content www.computing.net/answers/unix/where-to-find-c-head-files-in-unix-system-no-content/957.html

how to read binary files in Unix www.computing.net/answers/unix/how-to-read-binary-files-in-unix/4566.html

How to get latest updated file in a folder www.computing.net/answers/unix/how-to-get-latest-updated-file-in-a-folder/8497.html