06-20-2009
paste file1 file2| awk '{ printf "%-6s %-7s\n",$1,$2 }'
paste will merge your files tab separated as durden_tyler said and awk will format the output in lines with 2 strings separated by a space, both left alligned, assuming that the first column contains strings not longer than 6 characters and the second one not longer than 7 characters. This is just an example, adjust the length to the "real" data.
8 More Discussions You Might Find Interesting
1. Programming
How I can get the current make-file name in a make-file
So, if I run make with specified file:make -f target.mak
is it possible to have the 'target' inside of the that 'target.mak' from the file name? (2 Replies)
Discussion started by: alex_5161
2 Replies
2. Shell Programming and Scripting
Hi,
I'm working on a perl-awk loop combination and what I want to do is read in the first line of values.exp and pass that value to test1.exp; next, read in the second line of that file and pass that value to test2.exp.
Which would mean:
values.exp:
1.2
1.4
test1.exp
1
test2.exp... (10 Replies)
Discussion started by: tobias1234
10 Replies
3. Shell Programming and Scripting
Hi,
First of all sincere apologies if I have posted in a wrong section ! Please correct me if I am wrong !
I am very new to UNIX scripting.
Currently my problem is that I have a code file at the location /home/usr/workarea/GeneratedLogs.log :-
Code :-
(Feb 7, 571 7:07:29 AM),... (4 Replies)
Discussion started by: acidburn_007
4 Replies
4. Shell Programming and Scripting
Hi,
I am having trouble while using 'sed' with reading files. Please help. I have 3 files. File A, file B and file C. I want to find content of file B in file A and replace it by content in file C.
Thanks a lot!!
Here is a sample of my question.
e.g. (file A: a.txt; file B: b.txt; file... (3 Replies)
Discussion started by: dirkaulo
3 Replies
5. Shell Programming and Scripting
hi all,
i had the below script
x=`cat input.txt |wc -1`
awk 'NR>1 && NR<'$x' ' input.txt > output.txt
by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies
6. Shell Programming and Scripting
Hello ppl
I have a requirement to split (cut in unix) a file (A.txt) which is a pipe delimited file into A1.txt and A2.txt
Now I have to join (paste in unix) this A2.txt with external file A3.txt to form
output file A4.txt which should be CSV (comma separated file) so that third party can... (25 Replies)
Discussion started by: etldev
25 Replies
7. Shell Programming and Scripting
Hi friends, here is my problem.
I have three files like this..
cat file1.txt
=======
unix is best
unix is best
linux is best
unix is best
linux is best
linux is best
unix is best
unix is best
cat file2.txt
========
Windows performs better
Mac OS performs better
Windows... (4 Replies)
Discussion started by: Jagadeesh Kumar
4 Replies
8. UNIX for Beginners Questions & Answers
]I would like to make the second file label 'b' print down the first file label 'a', like shifting down the file creating new lines I want it to print all the way down until the first line of the second file hit the last line of the first file. Would I have to put this into a file itself or could I... (24 Replies)
Discussion started by: bigvito19
24 Replies
paste(1) General Commands Manual paste(1)
NAME
paste - merge same lines of several files or subsequent lines of one file
SYNOPSIS
file1 file2 ...
list file1 file2 ...
list] file1 file2 ...
DESCRIPTION
In the first two forms, concatenates corresponding lines of the given input files file1, file2, etc. It treats each file as a column or
columns in a table and pastes them together horizontally (parallel merging). In other words, it is the horizontal counterpart of cat(1)
which concatenates vertically; i.e., one file after the other. In the option form above, replaces the function of an older command with
the same name by combining subsequent lines of the input file (serial merging). In all cases, lines are glued together with the tab char-
acter, or with characters from an optionally specified list. Output is to standard output, so can be used as the start of a pipe, or as a
filter if is used instead of a file name.
recognizes the following options and command-line arguments:
Without this option, the new-line characters
of all but the last file (or last line in case of the option) are replaced by a tab character. This option allows replac-
ing the tab character by one or more alternate characters (see below).
list One or more characters immediately following replace the default tab as the line concatenation character. The list is
used circularly; i.e., when exhausted, it is reused. In parallel merging (that is, no option), the lines from the last
file are always terminated with a new-line character, not from the list. The list can contain the special escape
sequences: (new-line), (tab), (backslash), and (empty string, not a null character). Quoting may be necessary if charac-
ters have special meaning to the shell. (For example, to get one backslash, use ).
Merge subsequent lines rather than one from each input file.
Use tab for concatenation, unless a list is specified with the option. Regardless of the list, the very last character of
the file is forced to be a new-line.
Can be used in place of any file name
to read a line from the standard input (there is no prompting).
EXTERNAL INFLUENCES
Environment Variables
determines the locale for the interpretation of text as single- and/or multi-byte characters.
determines the language in which messages are displayed.
If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty
variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of
If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See
environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
RETURN VALUE
These commands return the following values upon completion:
Completed successfully.
An error occurred.
EXAMPLES
List directory in one column:
List directory in four columns
Combine pairs of lines into lines
Notes
works similarly, but creates extra blanks, tabs and new-lines for a nice page layout.
DIAGNOSTICS
Except for the option, no more than - 3 input files can be specified (see limits(5)).
AUTHOR
was developed by OSF and HP.
SEE ALSO
cut(1), grep(1), pr(1).
STANDARDS CONFORMANCE
paste(1)