Shell Script Problems, Lose formatting when copy pasting from formatted file.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script Problems, Lose formatting when copy pasting from formatted file.
# 1  
Old 08-15-2011
Shell Script Problems, Lose formatting when copy pasting from formatted file.

Hello,

I'm having trouble with formatting some text via the terminal. I can get it perfectly formatted, but when I try and copy paste the text from the output file it loses it's formatting. Very frustrating!

Basically I have 7 files (data data2 data3 data4 data5 data6 data7) containing a column of information each. I merge them all into one output file, with a separate column for each input file using:

HTML Code:
paste data data2 data3 data4 data5 data6 data7 | awk  '{printf "%-12s%-12s%-12s%-12s%-12s%-12s%-12s\n", $1, $2, $3, $4, $5,  $6, $7}' > output
The result looks good in the output file and when the output is displayed in the Terminal, but when I copy paste from the output file into another file the columns become all jumbled.


I've also tried:
HTML Code:
pr -m -t data data2 data3 data4 data5 data6 data7 >| expand > output
I have no idea what to do to solve this, any help would be greatly appreciated.
# 2  
Old 08-15-2011
Quote:
Originally Posted by facetoe
The result looks good in the output file and when the output is displayed in the Terminal, but when I copy paste from the output file into another file the columns become all jumbled.
What's the meaning of "copy paste", not by command cp?
# 3  
Old 08-15-2011
Thanks for the reply,

No not by the command cp. I can't use cp in this case.

I was thinking maybe I can make the columns by inserting spaces somehow to hold the columns in place, but I'm not sure how to go about it. This is how the output ends up:

HTML Code:
TUE      WED        THU          FRI    SAT      SUN        MON
16      17        18          19    20      19        17
Showers      Morning   Mostly    Mostly    Afternoon Numerous  Rain
Early.      Clouds.   Sunny.    Sunny.    Clouds.      Showers.  Early.
Mostly      Mild.        Mild.     Mild.    Mild.      Mostly    Morning
Sunny.                  Breezy.    Breezy.      Cloudy.   Clouds.
Cool.                          Mild.        Cool.
Windy.                          Breezy.   Breezy.
But when it is displayed in the terminal it looks perfect. Is there a way to dynamically assign spaces to hold the formatting in place?
# 4  
Old 08-15-2011
This is a very good suggestion (from the forum rules):
Quote:
Additional helpful guidelines for all posters (for better, faster replies to questions):

(A) Include as many pertinent details as possible in your post. Useful information usually includes: Vendor and version of hardware or software you are using, hardware platform, kernel version (if applicable).
# 5  
Old 08-15-2011
I think it is a simple font selection issue in the application window.

Please try using a non-proportional (fixed width) true type font.

OK
# 6  
Old 08-16-2011
Thanks for the suggestion ananthap but it didn't work.

---------- Post updated at 10:09 PM ---------- Previous update was at 10:06 PM ----------

Here you go yazu:

Code:
Hardware Overview:

      Model Name: MacBook
      Model Identifier: MacBook6,1
      Processor Name: Intel Core 2 Duo
      Processor Speed: 2.26 GHz
      Number Of Processors: 1
      Total Number Of Cores: 2
      L2 Cache: 3 MB
      Memory: 5 GB
      Bus Speed: 1.07 GHz
      Boot ROM Version: MB61.00C8.B00
      SMC Version (system): 1.51f53
System Software Overview:

      System Version: Mac OS X 10.6.5 (10H574)
      Kernel Version: Darwin 10.5.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Secure Virtual Memory: Enabled
      64-bit Kernel and Extensions: No
      Time since boot: 1 day12:44

# 7  
Old 08-16-2011
Smilie Well, Mac OS X would be enough (I thought maybe you are on windows with PuTTY or something like).
Do you get the "output" file on your local computer or you use some remote connection? If on the local one then why do you paste from terminal window and not from some editor opening your "output"?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script for formatted output

06/26/2017 23:40:40 CAUAJM_I_10082 06/26/2017 23:40:40 CAUAJM_I_40245 EVENT: CHANGE_STATUS STATUS: STARTING JOB: IOALPPRXXBD_ALPGLGENFAALL MACHINE: aspsun14 06/26/2017 23:40:42 CAUAJM_I_40245 EVENT: CHANGE_STATUS STATUS: RUNNING JOB:... (10 Replies)
Discussion started by: Sandeep Behera
10 Replies

2. Shell Programming and Scripting

Does a variable lose its value outside the loop in shell script?

hi, when we assign a variable inside a for loop or while loop in a shell script, does it loses its value after comming out of the loop. i am facing this issue. can anyone help me?? (8 Replies)
Discussion started by: Little
8 Replies

3. Shell Programming and Scripting

Formatting a file using shell script

Hi, Please find the below lines of a file B1/OT "GIB10" 837 130308 1351 MONORONOUS DIGI PATH FAULT SUPER B1/OT "GIB10" 520 130418 1537 MONORONOUS DIGI PATH FAULT SUPER B1/XT "GIB10" 762 130421 0653 TV Y-CEIVER ADMIN RXOCF-62 241_OKEBOLE_NEW 1 B1/XT "GIB10" 385 130425 1931 TV Y-CEIVER... (2 Replies)
Discussion started by: Ardhendu
2 Replies

4. Shell Programming and Scripting

Formatting File Using Shell Script

Hi Team, We have a requirement where we need to format input file using shell script by meeting the below conditions. 1. 1. Ignore first 549 characters of that file. 2. 2. After that we need to make a file of 100 characters per line, repeat it until the 3rd ... (16 Replies)
Discussion started by: ataneja7
16 Replies

5. Shell Programming and Scripting

AWK/Shell script for formatting data in a file

Hi All, Need an urgent help to convert a unix file in to a particular format: **source file:** 1111111 2d2f2h2 3dfgsd3 ........... 1111111 <-- repeats in every nth line. remaining all lines will be different 123ss41 432ff45 ........... 1111111 <-- repetition qwe1234 123weq3... (1 Reply)
Discussion started by: rajivnairfis
1 Replies

6. Shell Programming and Scripting

Formatting a file using shell script

I have a file with contents something similar to as below : SVCNAME,12m-1a,1a-2a,2a-3a,3a-4a,5a-6a,6a-7a,7a-8a,8a-9a,9a-10a,10a-11a,11a-12n,12n-1p,13p-14p,14p-15p,15p-16p,16p-17p,17p-18p,18p-19p,19p-20p,20p-21p,21p-22p,22p-23p,11p-12m, TOTALS... (5 Replies)
Discussion started by: deo_kaustubh
5 Replies

7. Shell Programming and Scripting

Shell script to copy file

Dear all, I have a database with thousands of files with the structure of name is: Filename_hour_year.abc Filename_hour_year_1.abc .............. So what I need is how to write a script that all file with contain the character "_1" will copy to "_2" For example: file name:... (7 Replies)
Discussion started by: hainguyen1402
7 Replies

8. Shell Programming and Scripting

Formatting the text file using shell script

How to add the filename to end of each line with | as seperator, except first and last line of the file(s) in directories(with diff tree structure) using shell script?. And also how to replace a list of strings with another set of strings, which is present in a file?. Kindly help out on... (1 Reply)
Discussion started by: av_vinay
1 Replies

9. Shell Programming and Scripting

Formatted output of shell script

Hello, I am working on one script which is giving output as a pipe "|" separated abcd | efgh | 20090745 abcdefgh | efg | 20090622 Can any one please help me i want it to be formatted as pipe will be aligned, or the output looks like a table. (2 Replies)
Discussion started by: vikash_k
2 Replies

10. Shell Programming and Scripting

formatting a file using shell script

Hi I have to do the following.I have to format a file test.t The contents are # Header 1231 xyz asdf asdapsdcsd //string1 = "pqrs" //string1 = "abcd"; //info //string1 = "*pqrs"; //add string1 = "#123"; //sub //string1 = "#1234567890" data = check(string1) //string1 = "#1234567890"... (12 Replies)
Discussion started by: gopsman
12 Replies
Login or Register to Ask a Question