By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,603 Members | 1,053 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,603 IT Pros & Developers. It's quick & easy.

UNIX - Reading the input to a shell Scrip from a File

P: 6
Hi,

I have a shell script, test.ksh which should read the input from another file, say 1.txt

test.ksh:

#!/usr/bin/ksh

datasource=$1

echo "Data is: $datasource


1.txt:

12345

When I run the command:

$test.ksh < 1.txt

It does not read the varibale properly from the file.

The scrip works fine when I type:

$test.ksh 12345


Thanks for help.
Sep 23 '07 #1
Share this Question
Share on Google+
1 Reply

P: 60
Hi,

I have a shell script, test.ksh which should read the input from another file, say 1.txt

test.ksh:

#!/usr/bin/ksh

datasource=$1

echo "Data is: $datasource


1.txt:

12345

When I run the command:

$test.ksh < 1.txt

It does not read the varibale properly from the file.

The scrip works fine when I type:

$test.ksh 12345


Thanks for help.
Hi try this one,
--------------------------------------
#!/bin/ksh

1.txt > datasource
one=$(cat datasource)
echo "Date is: $one"
--------------------------------------
Sep 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.