LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to append columns form a column file in another file (https://www.linuxquestions.org/questions/programming-9/how-to-append-columns-form-a-column-file-in-another-file-585404/)

adam_blackice 09-17-2007 07:15 PM

how to append columns form a column file in another file
 
hello all


i want to know how to write abash script that append columns form a column file in another file

ia have tried many things but it failed


cut -f 1 -d " " test1 >> hello.txt & cut -f 2 -d " " >> hello.txt


awk '{print $1}' test1 > hello.txt | cut -f 2 -d " " >> hello.txt


awk '{print $1}' test1 > hello.txt && cut -f 2 -d " " >> hello.txt


can any one give me a help and any help will be appreciated

homey 09-17-2007 07:45 PM

Maybe something like this...
Code:

cut -d" " -f1,2 file.txt > file1.txt
or
awk '{print$1" "$2}' file.txt > file1.txt


adam_blackice 09-17-2007 08:10 PM

tahnks for you help but what i mean i want to append 2 columns from 2 different files to another file :

the contents of the first file :
adams smith
sara wittel

the contents of the second file :

age 22
age 33


after appending will make new file has the contents

adams 22
sara 33

homey 09-17-2007 10:26 PM

sorry, misunderstood that part.
Maybe paste will do...
Code:

paste -d" " file1.txt file2.txt | cut -d" " -f1,4 > file3.txt

adam_blackice 09-17-2007 11:33 PM

thanks very much :)


All times are GMT -5. The time now is 05:58 AM.