|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Arranging columns in a line
Hi, Please give a solution... Current File Code:
200101701 A 5 B 283 D 222 200085506 A 5 B 6 C 304 200081406 A 5 200101784 D 1111 Desired Output Code:
200101701 A 0005 B 0283 * * D 222 200085506 A 0005 B 0006 C 0304 * * 200081406 A 0005 * * * * * * 200101784 * * * * * * D 1111 Sorry for formating related issues... Thank Last edited by Scrutinizer; 01-08-2013 at 02:54 AM.. Reason: removed img def |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
What have you tried so far?
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
I am trying to solve using awk...
|
|
#4
|
||||
|
||||
|
What did you try while using awk?
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
try: Code:
awk '
BEGIN {str="ABCD"; l=length(str)*2}
{for (i=3; i<=NF; i+=2) $i=sprintf("%04d", $i);
for (i=2; i<=l; i+=2) {
j=index(str,$i);
for (m=i/2; m<j; m++) { $i="*" OFS "*" OFS $i; $0=$0; }
}
for (i=(NF-1)/2; i<l/2; i++) { $(NF+i)="*" OFS "*"; }
$0=$0;
}
$1=$1
' OFS="\t" infile |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Help in arranging the output | Sudeep Bhattad | Shell Programming and Scripting | 4 | 10-25-2012 03:21 AM |
| Arranging data | bobo | UNIX for Dummies Questions & Answers | 3 | 01-20-2012 02:15 PM |
| arranging columns with AWK | sramirez | Shell Programming and Scripting | 2 | 12-12-2010 02:06 PM |
| Averaging 100 columns together line by line | jenjen_mt | UNIX for Dummies Questions & Answers | 2 | 08-03-2010 01:31 PM |
| need help in arranging the alias | upengan78 | Shell Programming and Scripting | 4 | 07-09-2010 04:29 PM |
|
|