Find the answer to your Linux question:
Results 1 to 2 of 2
Hello member's I'm learning to script in the ksh environment on a Solaris Box. I have 10 files in a directory that I need to pass, as input to a ...
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    2

    shell script to auto process ten random files and generate logs

    Hello member's

    I'm learning to script in the ksh environment on a Solaris Box.

    I have 10 files in a directory that I need to pass, as input to a batch job one by one. lets say, the files are named as follows:
    abcd.txt ; efgh.bat ; wxyz.temp etc. (random filenames with varied extensions ).

    How do I go about achieving the following :

    I want my batch script to take one file at a time from the current directory and process it, redirect the console output to a logfile (log1.txt, log2.txt etc )

    ./batch_script.ksh > log1.txt -- likewise, create 10 log files and exit

    for simplicity sake, contents of the script:
    Code:

    Code:
    #! /bin/ksh
    
    mv abcd.txt ./temp/
    echo "test script"
    
    ### End of Script ####
    Sorry if i sound vague. My problem definition is so silly, that I haven't managed to put it into simple words to explain my requirement better.

    regards,

    Kris

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    452
    > log.1.txt

    doing it this way, you lose the connection between the original
    file, and the logfile.

    how about using a different system of names, specifically,
    the filename with ".log" appended.

    some thing like this:

    for i in *
    do
    cat $i >$i.log
    done

    where in lieu of "cat" you have your processing script
    the sun is new every day (heraclitus)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...