| UNIX/Linux Forum Archives · Rules and Guidelines · Disclaimer |
Help
Search
Members
Calendar
|
| Welcome Guest ( Log In | Register ) | Resend Validation Email |
![]() ![]() ![]() |
| im4vip |
Posted: Apr 21 2005, 03:59 PM
|
|
Newbie ![]() Group: Members Posts: 8 Member No.: 890 Joined: 27-March 05 |
All,
Can some tell me how can I split a file into columns which has multiple de-limiter. i.e I have a file looks like Source of delivery: dbCristal Report date of data: 01.04.2005 Date of interface creation: 21.04.2005:11.12.01 aa.txt: 14791;bb.txt: 11709;cc.txt: 10839; My output need to be : aa.txt,14791 bb.txt, 11709 cc.txt, 10839 Can this be accompolished using awk/shell script ? Regs Srn |
| vibhor_agarwalin |
Posted: Apr 22 2005, 07:58 AM
|
|
User Level: 3 ![]() ![]() ![]() Group: Members Posts: 34 Member No.: 788 Joined: 1-February 05 |
Will something like this work
sed -e 's/:/,/g' | awk -F";" '{print $1,"\n",$2, ...} |
| im4vip |
Posted: Apr 22 2005, 12:50 PM
|
|
Newbie ![]() Group: Members Posts: 8 Member No.: 890 Joined: 27-March 05 |
Hi,
Thanks, However is there a way I can discard the all the lines above the required data i.e in this case required line is no 4, so i need to discard line 1,2,3. 1 Source of delivery: dbCristal 2 Report date of data: 01.04.2005 3 Date of interface creation: 21.04.2005:11.12.01 4 aa.txt: 14791;bb.txt: 11709;cc.txt: 10839; many thanks |
| vibhor_agarwalin |
Posted: Apr 25 2005, 05:02 AM
|
|
User Level: 3 ![]() ![]() ![]() Group: Members Posts: 34 Member No.: 788 Joined: 1-February 05 |
Just extend a bit.
cat file | grep ";" | sed -e 's/:/,/g' | awk -F";" '{print $1,"\n",$2, ...} |
| andyb1ack |
Posted: Apr 26 2005, 03:40 PM
|
||
|
User Level: 4 ![]() ![]() ![]() ![]() Group: Members Posts: 98 Member No.: 513 Joined: 9-September 04 |
You can replace all the ";" with an carriage return. I've done it here by escaping the carriage return (with a "\").
|
||
![]() |
![]() ![]() ![]() |