質問

To display text from a file do you have to use the command CP.

In my first snippet this is what worked fine:

#!/bin/ksh
#

count=$# #number of arguments

echo "Please enter filename to open:"
read file
cp $file temp
cat temp
echo "bye"

If i tried this command it doesn't work:

#!/bin/ksh
#

count=$# #number of arguments

echo "Please enter filename to open:"
read temp
#cp $file temp
cat temp
echo "bye"

It simply can't pick up the file in the second example. Does CP really need to be used?

役に立ちましたか?

解決

 cat temp

Tries to read a file called temp.

To read the file pointed to by the variable temp, use:

  cat $temp

You already do this correctly in your first example when you reference the variable file using $file.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top