To create a file with multiple lines from a shell script you can use the following recipe
rajulocal@hogwarts:~/work/tcsh$ cat add_multiple_lines_to_file.shRun this script using
#! /bin/tcsh -fx
mkdir -p ~/x
cat << EOF > ~/x/junk1
k
am
ara
ju
EOF
rajulocal@hogwarts:~/work/tcsh$ ./add_multiple_lines_to_file.shThe output will be stored in ~/x/junk1
mkdir -p /home/rajulocal/x
cat
rajulocal@hogwarts:~/work/tcsh$ cat ~/x/junk1For further information
k
am
ara
ju
- read the section on "Here-documents" in http://docstore.mik.ua/orelly/unix/ksh/ch07_01.htm
- http://en.wikipedia.org/wiki/Here_document
- search for "here document" in google
No comments:
Post a Comment