0

I want to use a directory name as a parameter for a pre-made script. Then the output goes into a newly made file in the home directory. It involves pipe/redirection. How do I do that?

read dir $dir > script > outputfile 
2
  • ok I figured out the syntax something like: script<$dir >|outputfile but it doesn't seem to accept directory as a parameter unless I entered it wrong. and how can I choose home directory as the location for outputfile? Commented Sep 28, 2014 at 5:34
  • you have to use script < $dir > ~/outputFile. Here ~ is the home directory. Commented Sep 28, 2014 at 6:07

1 Answer 1

1

If you want to use the directory name as-is in your script, pass it as a parameter:

script $dir > outputfile 

You can't redirect a directory to a script, what do you expect to see as the input? The name? The names of the directory entries? The contents of the directory entries? etc.

I'm assuming as you're writing scripts, you know how to process a parameter. What exactly are you trying to accomplish? Show the script. It's not a homework assignment, is it?

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.