1

All,

I have a file (called, say, bundled_file.txt) of here docs stored in a directory, and the file looks like this:

cat > a.txt << 'eof'
...
...
...
'eof'
cat > b.txt << 'eof'
...
...
...
'eof'
cat > c.txt << 'eof'
...
...
...
'eof'

I want to un-bundle this file so that the files a.txt, b.txt, and c.txt get created in the same directory as the original bundled file above.

Normally, I would just cd to this directory and run something like csh bundled_file.txt, but I want to execute the csh command while in my pwd (print working directory).

However, when doing a remote execution from my pwd, the files a.txt, b.txt, and c.txt get created there. I do not want this.

And, in case you're already thinking it, I do not want to change the files to say something like,

cat > /full/file/path/a.txt << 'eof'
...
...
...
'eof'

Any one who can help a novice out?

Thanks!

2

1 Answer 1

0

Self-answer ...

Let's say the file bundled_file.txt is in the folder called test ... and let's further say that my pwd is in the directory above, meaning the parent directory of test ...

I found this, which works well even though it's changing the pwd, but it immediately returns to the parent directory:

In bash, something like —

(cd ./test && csh bundled_file.txt)

Doing this, files a.txt, b.txt, and c.txt all get created in the folder test, and the pwd stays unchanged outside the subshell.

Feel free to respond to this if you have a better answer. 😊

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .