Use of the PASTE command in a script file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Use of the PASTE command in a script file
# 1  
Old 02-03-2013
Use of the PASTE command in a script file

Hi,

When I use the paste command in the terminal window it works fine, but when i try to use it in a bash script file i get errors. I'm not sure how to use the paste command in a bash script file.

my paste command looks like this

Code:
paste <( code1 ) <(code2)

thanks
# 2  
Old 02-03-2013
How do you call your script? How are you ensuring that bash is used to execute the script and not some other shell?
# 3  
Old 02-03-2013
This what my bash looks like


Code:
#!/bin/bash
echo $(paste <( code1 ) <(code2))

and i use this to execute it

Code:
sh test.sh

thx
# 4  
Old 02-03-2013
sh is not the same as bash, so either use:
Code:
bash test.sh

or
Code:
./test.sh

To be able to execute the latter command you need to make the script executable first using chmod.
This User Gave Thanks to Scrutinizer For This Post:
# 5  
Old 02-03-2013
Hmm i tried with the bash test.sh and works as expected. So i assume it's not possible to make the paste code work using the sh command of the bash ?

thx
# 6  
Old 02-03-2013
bash provides many functionalities that sh does not, for instance "process substitution" that you use in your code sample.
You need to output to two files, and paste those, or you need to play dirty tricks, like
Code:
$ mkfifo J
$ { code1; } | paste - J &      # paste stdin and the FIFO; put in background
$ { code2; } > J                # print to FIFO
$ rm J

This User Gave Thanks to RudiC For This Post:
# 7  
Old 02-03-2013
Interesting, ok thank you guys. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Paste command not working in shell script

Hai , When i use paste command in command prompt its giving expected output but not in the script. Below is the example. $cat file 1 2 3 $cat file1 4 5 6 $paste -d ':' file file1 1:4 2:5 3:6 but when i used the same command in script its giving the output as below : 1 2 3 (3 Replies)
Discussion started by: Subbu123
3 Replies

2. Shell Programming and Scripting

How do I use paste command in while condition??

there are lot of files where in mostly all the file contains 2columnsAl,1 Ail,13 Al,3 Al,1 Al,3 Al,2 Al,3 Al,1 Al,1 Al,1 My requirement is i wanted only the second column of every file as a column ony in the base file... I used paste command... but it is not helping as I'm using while... (7 Replies)
Discussion started by: nikhil jain
7 Replies

3. Shell Programming and Scripting

Using paste command every nth number of file

Hi, I want to use paste command in a loop that does it every 6 files. My sample files are like the ones below. 20010101.txt 20010106.txt 20010111.txt 20010116.txt 20010121.txt 20010126.txt 20010131.txt 20010205.txt 20010210.txt 20010215.txt 20010220.txt 20010225.txt 20010302.txt... (4 Replies)
Discussion started by: ida1215
4 Replies

4. Shell Programming and Scripting

Can't paste in command line.

Hello. I've made a simple script which asks the user to input a hash and then runs a command that replaces the variable $hash with what the user inserted. The ting is that when the programm asks for input I can't paste anything there..! any clues?? :wall: (8 Replies)
Discussion started by: louboulos
8 Replies

5. Shell Programming and Scripting

need help with cut and paste command

I have a file which contains 3 fields separated by tabs example andrew kid baker I need to swap kid and baker using cut and paste commands how is this to be done? Thanks (3 Replies)
Discussion started by: drew211
3 Replies

6. UNIX for Dummies Questions & Answers

paste command

input1 15 150 input2 x 10 100 input3 y 20 200 z 34 44 cmd paste -d "\t" input1 input2 input3 >>output output (1 Reply)
Discussion started by: repinementer
1 Replies

7. Shell Programming and Scripting

read file column and paste it in command

Hi Unix gurus I have a file containing 2 coloumns. I would like to do a script which reads the lines and executes a command like this: command <field1> parameters <field2> some more parameters Please let me know how you would do this without AWK, SED or any other mini language (for special... (5 Replies)
Discussion started by: BearCheese
5 Replies

8. Shell Programming and Scripting

Paste command issue

Problem with Paste command :) Hi All, i need small suggestion in my below script... i have output in .txt format like below file1.txt 01111111 02222222 03333333 file2.txt 230125 000012 000002 now i want to merge both the file in xls or csv formate now i am using the below... (2 Replies)
Discussion started by: Shahul
2 Replies

9. Shell Programming and Scripting

Perl script assistance; paste word into external command

I'm attempting to create a Perl script that will: Take the contents of the usernames.tmp file (usernames.tmp is created from an awk one-liner ran against /etc/passwd) Take one line at a time and pass it to the su command as a users name. This should go on until there is no more name to... (10 Replies)
Discussion started by: bru
10 Replies

10. UNIX for Advanced & Expert Users

paste command

I wonder if any body can help me with a command i am struggling with. I have a file with around 400 lines in, in a program i have it pulls out each line at a time so that data from the line can be cross referenced with another file. If it finds a match it pulls out a ocde from the second file, this... (5 Replies)
Discussion started by: mariner
5 Replies
Login or Register to Ask a Question