Paste Command does not align my output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Paste Command does not align my output
# 1  
Old 09-05-2008
Computer Paste Command does not align my output

I'm trying to "paste" two files but the result is not aligned.

File1 looks like this:
dog.csv
cat.csv
elephant.csv
cougar.csv

File2 looks like this:
2323
33
444
545545

Then I run a paste command:
paste File1 File2 > result.cnt

Then result.cnt file is created like this:
dog.csv 2323
cat.csv 33
elephant.csv 4444
cougar.csv 545545

but I want my result to be as something like the following

dog.csv..........2323
cat.csv..........33
elephant.csv...4444
cougar.csv.....545554

(Please take the dots (...) as spaces, I put them because the original post was ignoring the spaces)
So at the end I need the second column (numbers) to start at the same position.

Please advise!. Smilie

Last edited by jplayermx; 09-05-2008 at 02:26 PM.. Reason: my results was not published correctly
# 2  
Old 09-05-2008
The examples of correct and incorrect output look identical, but I suppose you might mean something like this.

Code:
paste File1 File2 | column >result.cnt

# 3  
Old 09-05-2008
The incorrect an correct are not identical.

My incorrect output shows the numbers right one space after the animal file names but what I need is to put the all numbers aligned in a second column.

Then result.cnt file is created like this:
dog.csv 2323
cat.csv 33
elephant.csv 4444
cougar.csv 545545

but I want my result to be as something like the following
....................<-I need the number to start here
dog.csv.........2323
cat.csv..........33
elephant.csv...4444
cougar.csv.....545554
(Please take the dots (...) as spaces, I put them because the original post was ignoring the spaces)


I tried your code but got an error "ksh: column: not found"
# 4  
Old 09-05-2008
Try the following
Code:
$ paste File1 File2 | awk '{ printf "%-20s %s\n", $1, $2 }'

# 5  
Old 09-05-2008
You are the best fpmurphy!!!! It worked!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Better Align--output of find command

Hi, i have sh program which search for a file in a folder structure and provides its path. This is just used to see if that file exits more that once anywhere down the folder structure. I have used find command to search & printing it output on terminal. I have attached screen shot of it.... (10 Replies)
Discussion started by: praveenkumar198
10 Replies

2. Shell Programming and Scripting

Issue with paste command

Hi, I am facing issue with paste command. It is adding spaces or tab in between. I have say 3 files with below data File_1 TH THI THIS I File_2 IS IS S IS RE S File_3 RECORD 1 CORD 2 IS RECORD 3 (3 Replies)
Discussion started by: Simanto
3 Replies

3. UNIX for Advanced & Expert Users

Paste command formatting

Hi, I was trying to concatenate some files using paste command along with some formatting but getting stuck. The problem is: cat 1.txt A cat 2.txt B C cat3.txt D E cat 4.txt G H (5 Replies)
Discussion started by: abhi1988sri
5 Replies

4. Shell Programming and Scripting

Paste command - question

Hi, Below file content is output from pasting two files. Now, i want to output another file which just contains the difference on any line For example: JAY,2,,3,5,B+,JAY,2,,3,5,B+ ANN,5,,5,1,C,ANN,5,,5,2,C Line JAY seems to have no difference. However, line ANN has difference in on... (3 Replies)
Discussion started by: jakSun8
3 Replies

5. Shell Programming and Scripting

Help! Paste Multiple SQL output result to exec command

Hi, I want to write the shell script to change multple file name (the file name is get from DB) e.g. cp db1.txt file1_new.txt cp db2.txt file2_new.txt cp db3.txt file3_new.txt I have write the script like this: VAR=`sqlplus -s $LOGON @<<ENDOFTEXT set termout off ... (0 Replies)
Discussion started by: jackyntk
0 Replies

6. UNIX for Dummies Questions & Answers

paste command

input1 15 150 input2 x 10 100 input3 y 20 200 z 34 44 cmd paste -d "\t" input1 input2 input3 >>output output (1 Reply)
Discussion started by: repinementer
1 Replies

7. Shell Programming and Scripting

Paste command issue

Problem with Paste command :) Hi All, i need small suggestion in my below script... i have output in .txt format like below file1.txt 01111111 02222222 03333333 file2.txt 230125 000012 000002 now i want to merge both the file in xls or csv formate now i am using the below... (2 Replies)
Discussion started by: Shahul
2 Replies

8. Shell Programming and Scripting

Need a Help with paste 2 files since the output is not what i want

Need a Help with paste 2 files since the output is not what i want ie: i have 2 files pwd /home/pavargaz/alejo/scan01/nokia/2006/abril/bavaria/chu0 $ cat filechu chu0 dia Cantidad 01 257 02 262 03 260 04 58 $pwd ... (3 Replies)
Discussion started by: alexcol
3 Replies

9. UNIX for Dummies Questions & Answers

How to underline/bold and how to align output

Hi, I work with AIX 5 and have two basic questions: 1) How do I underline/bold a word in a text output? Any way to do it with echo command? basic example: echo "FOLDER " >> folder.txt ( I wish the word FOLDER to be underlined and bold). 2) Suppose I have the following pipe delimited... (1 Reply)
Discussion started by: clara
1 Replies

10. UNIX for Advanced & Expert Users

paste command

I wonder if any body can help me with a command i am struggling with. I have a file with around 400 lines in, in a program i have it pulls out each line at a time so that data from the line can be cross referenced with another file. If it finds a match it pulls out a ocde from the second file, this... (5 Replies)
Discussion started by: mariner
5 Replies
Login or Register to Ask a Question