![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| To cut entire column from a file and apend it to another file as another column | sakthifire | Shell Programming and Scripting | 4 | 06-25-2008 01:27 AM |
| Inserting a column in a file | dhanamurthy | Shell Programming and Scripting | 7 | 05-11-2008 07:29 AM |
| How to check Null values in a file column by column if columns are Not NULLs | Mandab | Shell Programming and Scripting | 7 | 03-15-2008 05:57 AM |
| inserting into a data file | paul1s | UNIX for Dummies Questions & Answers | 4 | 10-12-2006 11:47 PM |
| Inserting argument into top of a file | Dev06 | UNIX for Dummies Questions & Answers | 7 | 10-05-2006 01:16 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Inserting a new column in a file
Hey..
I'm writing a code to download some stuff from Informix database and put it on Xls. It works fine, but I have a problem fitting in a new requirement. I have currently a file which has information like below. f_name|Ronnie|Johnson|23.00| f_sal|Ronnie|Jhonson|4000.00| f_dept|Finance|Jr.Asst|23| Now I need to insert a new column with a description corresponding to field name and that value needs to be inserted before it. EmpName|f_name|Ronnie|Johnson|23.00| EmpSalary|f_sal|Ronnie|Jhonson|4000.00| EmpDept|f_dept|Finance|Jr.Asst|23| I'm not sure of how to insert a value before a text moving the whole line to the right.. any thoughts please... |
| Forum Sponsor | ||
|
|
|
|||
|
Try reeading the main page for join
IF you create a second file Code:
EmpName|f_name EmpSalary|f_sal EmpDept|f_dept |
|
|||
|
Tried.. doesn't work
Hey..
I tried the way u told me .. I'm on AIX actually.. In the first file there are multiple entries of the field name.. like f_name|Ronnie|Johnson|23.00| f_name|xxxx|yyyy|000| f_name|ssss|dddd|123| f_sal|Ronnie|Jhonson|4000.00| f_sal|xxxx|yyyy|000| f_sal|ssss|dddd|123| f_dept|Finance|Jr.Asst|23| I created a second file like f_name|EmpName f_sal|EmpSalary f_dept|EmpDept and did a simple join after sorting both the files.. join file1 file2 > file3. nothing happened. No error popped up an nothing is happening.. is AIX a problem.. i tried using "join -i" option but that is not available in AIX i guess. the number of rows in the two files are obviously not the same is there anyother way out ?? |
|
|||
|
Did you read the man page for join on AIX?
Code:
join -t\| -1 1 -2 1 -o 1.2,2.3,2.4 file2 file1 Code:
EmpName|Johnson|23.00 EmpName|yyyy|000 EmpName|dddd|123 EmpSalary|Jhonson|4000.00 EmpSalary|yyyy|000 EmpSalary|dddd|123 |