Visit Our UNIX and Linux User Community


linux 'paste' allignment problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting linux 'paste' allignment problem
# 1  
Old 10-30-2009
linux 'paste' allignment problem

Hi Everyone,
Code:
[root@]# cat 1
#!/usr/bin/perl
print "c\tc\t\n";
[root@]# cat 2
#!/usr/bin/perl
print "b\tb\t\n";
print "b\tb\t\n";
print "b\tb\t\n";

[root@]# perl 1 > 11
[root@]# perl 2 > 22
[root@]# cat 11
c       c
[root@]# cat 22
b       b
b       b
b       b
[root@]# paste 11 22
c       c               b       b
        b       b
        b       b

But the output should be:
Code:
c       c               b       b
                         b       b
                         b       b

means when i paste the output into excel, the alignment can be proper aligned. how to do that? Smilie

Thanks
# 2  
Old 10-30-2009
Y not the output can be like this ??

Code:
c       c               b       b
b       b
b       b

I mean based on what your expecting the lines 2 and 3 have to move away a bit.
# 3  
Old 10-30-2009
Hi panyam,

please see the attached 1.png.
Thanks
linux 'paste' allignment problem-1png
# 4  
Old 10-30-2009
In that case , you need to edit the first file , so that the second and third lines will have tabs
# 5  
Old 10-30-2009
There is a way i thought, and it works.
for exmaple, there are three txt.
1. use wc -l to get the max lines among those three txt.
3 1.txt
10 2.txt
34 3.txt
2. then use for loop for each file, 1.txt: 3 to 34; 2.txt: 10 to 34; 3.txt: 34 to 34, use print MYFILE "\t\t\t" to each txt.

Then paste should be no problem.
# 6  
Old 10-30-2009
Quote:
Originally Posted by jimmy_y
There is a way i thought, and it works.
for exmaple, there are three txt.
1. use wc -l to get the max lines among those three txt.
3 1.txt
10 2.txt
34 3.txt
2. then use for loop for each file, 1.txt: 3 to 34; 2.txt: 10 to 34; 3.txt: 34 to 34, use print MYFILE "\t\t\t" to each txt.

Then paste should be no problem.
Yes , good work Done. However the no of tab's to printed is based on the column count.

Previous Thread | Next Thread
Test Your Knowledge in Computers #934
Difficulty: Medium
The C standard library does not specify any specific resolution, epoch, range, or datatype for system time values.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in cut or paste

Hello, I have some problem in cut or paste command for my text data. Input1.txt : I use cut command : cut -d ' ' -f1 Input1.txt > result.txt result.txt : Then, I use paste command to merge result.txt. paste -d ' ' result.txt Input1.txt > output.txt output.txt showed : I use cut... (1 Reply)
Discussion started by: awil
1 Replies

2. Shell Programming and Scripting

Problem in Cut and paste

Hi, I have a file like this --> Consider z as space #cat filename ABC <!--Nzzzzz--> <!--RESUMO--> EFG XYZ <!--Nzzzzz--> <!--RESUMO--> I need to cut the <!--RESUMO--> part and paste it to the previous line so that the file will look like this--> ABC <!--Nzzzzz--><!--RESUMO-->... (4 Replies)
Discussion started by: samsonata
4 Replies

3. Solaris

Solaris v Ubuntu using OpenSSL paste problem

Hello, I hope this means something to someone. I have an odd problem that just started happening recently. I am not the system admin, so I don't have full info on any changes to the system lately. Except that I did upgrade OpenSSL to version 1.0.1.c from 1.0.0j. Anyway, I am trying to... (4 Replies)
Discussion started by: jonycp
4 Replies

4. UNIX for Dummies Questions & Answers

A copy paste problem with loops in bash

Hello All, i have a really strange copy paste problem. When I write some loops in an editor for example: for j in 1 2 3 do echo "$j" done and I want to paste it to the shell, the result in the shell is: for j in 1 2 3; do e; other commands work fine and if a copy paste... (4 Replies)
Discussion started by: creamcheese
4 Replies

5. Shell Programming and Scripting

Output allignment

Hi Guys, I hope you are doing good out there. I am facing some issues in the alligment of the output of a shell script. Below is the statement which is formatting the output:echo $File | awk -F '' '{print $13,$15="\t"$16,$4="",$5,$6,$7}' and its output is Domain Log file ... (2 Replies)
Discussion started by: singh.chandan18
2 Replies

6. UNIX for Dummies Questions & Answers

vi copy/paste problem

I'm having a problem copy/pasting from a txt file in windows to vi. What happens is I copy a chunk of text, go to the putty terminal, go into insert mode, and right click, and it will stop pasting at a random point and freeze up. Nothing I do gets out of it. This only happens on my account... (1 Reply)
Discussion started by: solidarity
1 Replies

7. UNIX for Dummies Questions & Answers

copy and paste certain many lines of huge file in linux

Dear All, I am working with windoes OS but remote a linux machine. I wonder the way to copy an paste some part of a huge file in linux machine. the contain of file like as follow: ... dump annealling all custom 10 anneal_*.dat id type x y z q timestep 0.02 run 200000 Memory... (2 Replies)
Discussion started by: ariesto
2 Replies

8. Shell Programming and Scripting

Allignment

Hi All, I want to shift the last and second last line to 8 spaces in the right inside a file. please can somebody suggest a script for the same. Thanks and Best Regards, Shazin (22 Replies)
Discussion started by: Shazin
22 Replies

9. UNIX for Dummies Questions & Answers

vi paste problem

i encountered a vi paste problem on aix platform. when i copied some sources from windows and then pasted it into a vi window, many <TAB>s were inserted automatically in front of each line. (i.e., one tab for line1 and two tabs for line2 and etc) but this problem cannot be repeated on linux... (2 Replies)
Discussion started by: wrl
2 Replies

10. Windows & DOS: Issues & Discussions

VNC copy paste problem

Hi, Am unable to cut & paste between the VNC windows client and local Windows machine. In few VNC windows client, i was able to do. (2 Replies)
Discussion started by: param_it
2 Replies

Featured Tech Videos