The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
paste several files tonet Shell Programming and Scripting 1 10-05-2007 07:08 AM
paste 2 files ( it is possible???) mig28mx UNIX for Dummies Questions & Answers 3 06-21-2007 08:51 AM
Paste the files contents differently er_aparna Shell Programming and Scripting 1 05-16-2007 01:29 AM
Need a Help with paste 2 files since the output is not what i want alexcol Shell Programming and Scripting 3 01-09-2007 12:47 AM
awk or sed or paste leprichaun UNIX for Dummies Questions & Answers 3 11-16-2003 03:58 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-01-2008
Registered User
 

Join Date: Jan 2006
Posts: 145
Red face paste more than 12 files together

Hi,

1. How can I get around the issue with pasting more than 12 files together?

2. paste file1 file2 > file3........how can I do this with awk??

Thanks!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-02-2008
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 497
Hi.

Using simple data files, intermediate files is one answer:
Code:
#!/bin/ksh -

# @(#) s1       Demonstrate pasting with intermediate files.

echo
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1) paste
set -o nounset
echo

FILE1=data1
FILE2=data2
FILE3=data3
FILE4=data4

echo
echo " Data file $FILE1:"
cat $FILE1

echo
echo " Data file $FILE2:"
cat $FILE2

echo
echo " Data file $FILE3:"
cat $FILE3

echo
echo " Data file $FILE4:"
cat $FILE4

echo
echo " Intermediate results:"
paste $FILE1 $FILE2 >t1
cat t1

echo
paste $FILE3 $FILE4 >t2
cat t2

echo
echo " Results of pasting intermediate result files:"
paste t1 t2

exit 0
Producing:
Code:
$ ./s1

(Versions displayed with local utility "version")
SunOS 5.10
ksh M-11/16/88i
paste - no version provided for /usr/bin/paste.


 Data file data1:
a
b
c

 Data file data2:
d
e
f

 Data file data3:
g
h
i

 Data file data4:
j
k
l

 Intermediate results:
a       d
b       e
c       f

g       j
h       k
i       l

 Results of pasting intermediate result files:
a       d       g       j
b       e       h       k
c       f       i       l
cheers, drl
Reply With Quote
  #3 (permalink)  
Old 4 Weeks Ago
broli's Avatar
Registered User
 

Join Date: Dec 2007
Location: Argentina
Posts: 148
use zsh
you can do that
Reply With Quote
  #4 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: Jan 2006
Posts: 145
Friends:

Solution 1 is ok. I am more interested in syntax using AWK to replace PASTE or other paste option to allow me to paste more than 12 files.

paste limit of only 12 files.


Solution 2 is not working. Please provide code. I tried it (zsh) not working.

Thanks!
Reply With Quote
  #5 (permalink)  
Old 4 Weeks Ago
broli's Avatar
Registered User
 

Join Date: Dec 2007
Location: Argentina
Posts: 148
i read it from here

The Linux and Unix Menagerie: Simple Multiple-Stream Output Redirection With Zsh On Linux and Unix
Reply With Quote
  #6 (permalink)  
Old 4 Weeks Ago
drl's Avatar
drl drl is offline
Registered User
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 497
Hi.

There is a perl version of paste at PPT: paste

This test script:
Code:
#!/bin/bash -

# @(#) s1       Demonstrate paste written in perl, Perl Power Tools Suite.

echo
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version =o $(_eat $0 $1)
set -o nounset

N=${1-15}

FILE1=data1
FILE2=data${N}

echo
echo " Sample: data file $FILE1:"
cat $FILE1

echo
echo " Sample: data file $FILE2:"
cat $FILE2

files=$( echo data? ; echo data?? )
echo
echo " Results:"
./paste.perl -d " " $files

exit 0
Produces this (with simple data files):
Code:
$ ./s1

(Versions displayed with local utility "version")
SunOS 5.10
GNU bash 3.00.16

 Sample: data file data1:
1.1
1.2

 Sample: data file data15:
15.1
15.2

 Results:
1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 11.1 12.1 13.1 14.1 15.1
1.2 2.2 3.2 4.2 5.2 6.2 7.2 8.2 9.2 10.2 11.2 12.2 13.2 14.2 15.2
Best wishes ... cheers, drl
Reply With Quote
  #7 (permalink)  
Old 4 Weeks Ago
Registered User
 

Join Date: Jan 2006
Posts: 145
friends:

Thank you for the replies. After look at all the replies, I think I din't make my questions clear. Here, it is again:
I have 13 files of data.
file1
cat fiel1
1

file2
cat file2
2

file3
cat file3
3

file4
cat file4
4

file5
cat file5
5

file6
cat file6
6

file7
cat file7
7

file8
cat file8
8

file9
cat file9
9

file10
cat file10
10

file11
cat file11
11

file12
cat file12
12

file13
cat file13
13

paste file1 file2 file3 file4 file5 file6 file7 file8 file9 file10 file11 file12
1 2 3 4 5 6 7 8 9 10 11 12

paste file1 file2 file3 file4 file5 file6 file7 file8 file9 file10 file11 file12 file13
limit 12 files only

QUESTION:
how can I paste these 13 files together? I want my results:
1 2 3 4 5 6 7 8 9 10 11 12 13

can this be done with awk,sed,per,......or......?

Any taker! Thanks!
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0