heredoc - How to have a shell script that unpacks several files when executed? -


i have several text files within shell script file unpack directory once script executed. i've been getting 'here-doc' solutions this:

cat>mytextfile.txt<<'eof' content eof 

however, shell scripts getting larger , beginning require more , more files unpacked. basically, making computational pipeline, , want distribute single shell script, needs expand several directories/subdirectories/files once run.

thanks!

you can embed in script uuencoded tar file , unpack this:

tar xf - <<eof uuencoded tarball eof 

you can encode data way:

$ tar cf - src_tree | compress | uuencode src_tree.tar.z >your_here_doc 

then paste file your_here_doc 'the uuencoded tarball' line now, this:

$ (echo tar cf - '<<eof'; cat your_here_doc; echo eof) >self_expanding_files.sh 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -