The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 07-04-2009
kshji's Avatar
kshji kshji is offline
Registered User
  
 

Join Date: Jun 2009
Location: Finland
Posts: 236
Try next cmdline, script caller set the output, script only read from stdin and write to stdout.
Code:
| $HOME/myscript.sh > $HOME/my.log
And myscript.sh, including also how to ex. to set uppercase without external command (ex. tr). Also no need to tell input, if it is stdin.
Code:
#!/usr/bin/ksh
typeset -u input
while read  input
do
     print "$input"
     # if you like to add line to some file, then
     # print some >> somefile
     # single > is overwrite = file include only the lastline
done
But if you like to put all while output to file then >> must be after done = end of while cmd.
Code:
while read line
do
     print some
done >> outfile
# or ex. done | outpipecmd > outfile
# all output, which are done between do-done goto outfile
Script are more generic, if script read from stdin and write to sdtout. Caller make define for input and output. Whole idea of *nix systems/commands - io-redirection and pipes.