Operating System - Linux
1753502 Members
4995 Online
108794 Solutions
New Discussion юеВ

Using paste command for 2 files

 
Yvette Johnson
Advisor

Using paste command for 2 files

I'm using the paste command to combine 2 files and redirect the output to a text file for importing to an Access database: first file contains a URL and second file contains job announcement number as they open daily. My command, paste file-url file-joa > file-text. The file-text looks like this: www.joc.com/cgi-bin/admin.pl?action=&num= TMA-05-5707-GW (there's a space between URL and job announcement number)

How can I get rid of the space or what command can I use? Another application will be using the Access database to retrieve the URL. So the URL cannot have a space in it. The reason for these files: the daily job announcements and Access database are stored on separate servers. Currently, I'm manually updating the Access database and I won't to automate the process. Thanks in advance for your help!
11 REPLIES 11
Mel Burslan
Honored Contributor

Re: Using paste command for 2 files

paste file-url file-joa | sed -e "1,1s/\ //" > file-text

this should work...

HTH
________________________________
UNIX because I majored in cryptology...
Yvette Johnson
Advisor

Re: Using paste command for 2 files

Thanks but my output text file have spaces in it.
Mel Burslan
Honored Contributor

Re: Using paste command for 2 files

yes, I understand that fact. The sed command in between the paste and output file redirection will filter out the space from being written to the output. It will not alter your input files.

did you at least try it and see it failing ?
________________________________
UNIX because I majored in cryptology...
Yvette Johnson
Advisor

Re: Using paste command for 2 files

Yes I did but I did not get a fail message.
Mel Burslan
Honored Contributor

Re: Using paste command for 2 files

and it still put that space in between the url and job number on the output file ?

is it possible for you to attach these files to a couple of messages here ? I am curious why it did not work ? all the command is doing is replacing a space character with nothing.
________________________________
UNIX because I majored in cryptology...
Patrick Wallek
Honored Contributor

Re: Using paste command for 2 files

Yvette,

Try this:

paste file1 file2 | awk '{print $1$2}' > file3


Mel -- I couldn't get your sed command to work either.
Yvette Johnson
Advisor

Re: Using paste command for 2 files

Patrick's command work.

Thanks for you help! Have a great weekend!

Yvette
Mel Burslan
Honored Contributor

Re: Using paste command for 2 files

sorry about the confusion. I tested myself and saw it is not working due to the wrong assumption that paste inserts a space between the fields. As a matter of fact paste inserts a tab character between the fields. I think Yvette's "space between the url and job number" statement mislead me.

somthing like this should be executed for the sed command to work as I was not able to trp the tab character with \t on the regexp

paste -d "++++++++++++" 1 2 | sed -e "1,1s/+//"

glad you got your result though
________________________________
UNIX because I majored in cryptology...
Arturo Galbiati
Esteemed Contributor

Re: Using paste command for 2 files

Yvette,
try this:
paste -d ' ' file1 file2|tr -d ' '

HTH,
Art