Help required on file formating


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help required on file formating
# 1  
Old 01-31-2008
Question 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?
# 2  
Old 01-31-2008
After the combine, do a sed

I think you followed how to do the paste command.
The sed command is replacing the pipe with a space and a pipe symbol.


> cat sfile1
name
nameabc
bcd
nameabcdefg

> cat sfile2
age
age1111
age2345
age6743

> paste -d"|" sfile1 sfile2 | sed "s/|/ |/g" >sfile3
> cat sfile3
name |age
nameabc |age1111
bcd |age2345
nameabcdefg |age6743
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with ... Formating the file using awk

I have a file like below position1 0 7802 7802 0 client1 - - position1 8 8032 8032 0 client1 ... (7 Replies)
Discussion started by: manas_ranjan
7 Replies

2. Shell Programming and Scripting

File formating

I need to create a fixed width file based on the column lengths. lets assume I have six(this may be dynamic) fields each are of different length column1=6 #size of the column column2=3 column3=2 column4=3 column5=4 column6=5 I tried below code snippet but it is not working echo... (4 Replies)
Discussion started by: gvkumar25
4 Replies

3. UNIX for Beginners Questions & Answers

File formating help

Hi all, I am having the file below I need that as below Thanks, Arun (12 Replies)
Discussion started by: arunkumar_mca
12 Replies

4. UNIX for Beginners Questions & Answers

File formating with lines

Hi All, Need to modify a file basically join the extra line to one I am having a file like below And would like to make it as below . (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

5. Shell Programming and Scripting

Help in formating a txt file

Pls help in formatting a txt file using shell scripting Input file format: Name priya 2010-09-21 10:43:49 TEXT ID 1 hi TEXT ID 2 how TEXT ID 3 r TEXT ID 4 u Output required: name priya hi how r u (4 Replies)
Discussion started by: bha148
4 Replies

6. UNIX for Dummies Questions & Answers

File formating help needed.

I have a file called vm.cfg . content of file. acpi = 1 apic = 1 builder = 'hvm' How would i write a script which will add boot = 'd' at 3rd line. For example. after running the script the file should be like below. acpi = 1 apic = 1 boot = 'd' builder = 'hvm' I dont want to... (3 Replies)
Discussion started by: pinga123
3 Replies

7. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

8. Shell Programming and Scripting

file formating in Perl

Hi, I am new to unix , I have a requirement for formating the input file and generate the output file as per the downstream requirement .. My application receiving a text input file having 4 field and my application need to check each field and if some value of a field is blank ..then it need... (1 Reply)
Discussion started by: julirani
1 Replies

9. Shell Programming and Scripting

File formating question.

Hi, I have a file with only data 1 row: AA#?BB#?CC#?DD Assume '#?' is the delimiter, i want the output in another file to be: AA BB CC DD Pls let me know if this is possible by sed ? Thanks in advance. (3 Replies)
Discussion started by: smc3
3 Replies

10. UNIX for Dummies Questions & Answers

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 (6 Replies)
Discussion started by: udiptya
6 Replies
Login or Register to Ask a Question