How do I pass a file as input to a script

How do I pass a file as input to a script

Post by Casey Ta » Thu, 12 Mar 1998 04:00:00



I am in the process of migration 500 database from one directory to 5
separate directories. I have already worked out which directories to split
the 500 database into and stored it into a text file eg. db.txt.

The format of the file is as follows:

    <database name>        <destination directory>
                    .                                            .
                    .                                            .
                    .                                            .

How do I pass the two parameters to the command of:

    mv <database name> <destination directory>

put it in a while loop till eof ?

Casey.

 
 
 

How do I pass a file as input to a script

Post by Grigoriy Stroki » Thu, 12 Mar 1998 04:00:00



> I am in the process of migration 500 database from one directory to 5
> separate directories. I have already worked out which directories to split
> the 500 database into and stored it into a text file eg. db.txt.

> The format of the file is as follows:

>     <database name>        <destination directory>
>                     .                                            .
>                     .                                            .
>                     .                                            .

> How do I pass the two parameters to the command of:

>     mv <database name> <destination directory>

> put it in a while loop till eof ?

> Casey.

I assume you have a file list.txt that contains strings like
------------------------
database1 dir1
database2 dir2
...
------------------------

Then use xargs:
  xargs -n 2 mv <list.txt

 
 
 

How do I pass a file as input to a script

Post by Glenn Wes » Thu, 12 Mar 1998 04:00:00



> I am in the process of migration 500 database from one directory to 5
> separate directories. I have already worked out which directories to split
> the 500 database into and stored it into a text file eg. db.txt.

> The format of the file is as follows:

>     <database name>        <destination directory>
>                     .                                            .
>                     .                                            .
>                     .                                            .

> How do I pass the two parameters to the command of:

>     mv <database name> <destination directory>

> put it in a while loop till eof ?

> Casey.

In the Bourne shell:

cat db.txt|while read dbName destDir
do
        mv $dbName $destDir
        if [ $? -ne 0 ]; then
                echo "Error moving $dbName to $destDir"
        fi
done

 
 
 

1. Redirecting input to a file - echo the input to screen/file?

Is it possible to have redirected input to a file also echoed to the
screen, or to a file?  For example, if I do something like the following:

$ ./program < input.txt > output.txt 2>&1

The output file shows everything coming out of the program (stdout and
stderr), but doesn't display the input.txt.

I tried adding 0>&1, but no-go (input hosed).

I can also cut and paste the input.txt file right in the shell, but it
doesn't show up for some reason in the shell (Redhat8.0).  Not sure what's
going on, any help appreciated.

2. Need advice on video card

3. linker input file unused because linking not done -- compile error message

4. Exclusive open of file

5. Running dos program in batch file in ext2fs partition as input

6. Adding patches eats disk space!

7. Nawk: can I use more than one input file in one script?

8. blank screen

9. Q:How to take streamed input & send to a file in a bsh script?

10. script to use file containing paths as input

11. Reading a file and passing it as a value to a script.

12. HELP - parsing text file as input to script - HELP

13. Script to convert file names to upper case and pass as arg to a prog