combine text and files in a script -
i have following problem: i'm trying write script 2 files (file1.txt , file2.txt) should combined 1 file text passage in between. output should written in file (e.g. output.txt).
the output.txt file should be:
[content of file1.txt] text passage [content of file2.txt]
after research on internet found following , works fine in terminal:
cat file1.txt <(echo "text passage") file2.txt > output.txt
however, not work in script:
#!/bin/sh cat file1.txt <(echo "text passage") file2.txt > output.txt
if execute script nothing happens (the output.txt isn't written).
why doesn't line work in script , can make work?
thank help!
stephan
you can this:
cat file1.txt > output.txt echo "text message" >> output.txt cat file2.txt >> output.txt
the >>
operator means add end of file, rather overwriting contents.
you can group commands using brackets:
(cat file1.txt echo "text message" cat file2.txt) > output.txt
Comments
Post a Comment