![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| Script required to get a required info from file. Pls. help me. | ntgobinath | Shell Programming and Scripting | 2 | 05-31-2008 08:34 AM |
| Help required on file formating | udiptya | UNIX for Dummies Questions & Answers | 1 | 01-31-2008 09:25 AM |
| Urgent help required in deleting a line without opening a file usinga shell script | naan | Shell Programming and Scripting | 6 | 07-20-2006 03:42 AM |
| Very Urgent help required in Shell Program | Suppandi | Shell Programming and Scripting | 1 | 12-09-2005 08:33 AM |
| A C program required for portability | nmsinghe | High Level Programming | 1 | 09-20-2002 12:34 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Shell program:Help required on file formating
I have two files file1 and file2 as shown below:
file1: name nameabc bcd nameabcdefg file2: age age1111 age2345 age6743 I have pasted one file on the other with the delimiter "|" and the resulttant file is: name|age nameabc|age1111 bcd|age2345 nameabcdefg|age6743 but I want it to be formatted like this: name |age nameabc |age1111 bcd |age2345 nameabcdefg |age6743 I tried it with "\t" but since the length of name can vary the number of tabs is not constant. Can anybody give a solution to this? |
|
||||
|
Hi what u suggested I have tried that already but the thing is I want to position them the parameters one below the other something like shown below
name\t\t\t\t\t\t\t|age nameabc\t\t\t\t\t|age1111 bcd\t\t\t\t\t\t\t\t|age2345 nameabcdefg\t\t\t|age6743 |
|
||||
|
file1:
name nameabc bcd nameabcdefg file2: age age1111 age2345 age6743 Above given are my two files. I have issued a command like echo "`paste -d'|' file1 file2`" > file3 I am getting file3 as: name|age nameabc|age1111 bcd|age2345 nameabcdefg|age6743 whereas I want the values to start from a single column. Something like file3: name\t\t\t\t\t\t\t|age nameabc\t\t\t\t\t|age1111 bcd\t\t\t\t\t\t\t\t|age2345 nameabcdefg\t\t\t|ge6743 All of the data in red should start from a fixed column! |
|
||||
|
Possible solution
Create a awk file called neatcols with the following contents
{ printf "%-20s %s\n", \ $1, substr($0, index($0,$2)) } then run it in awk -f neatcols file3 > file4 |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|