1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help with terminal project in Mac

  1. Sep 4, 2013 #1
    Hi
    I'm learning how to use terminal at school but there is one part of my assignment
    Write a command file (a .bat file on Windows, an .sh file on OSX/*nix) containing the following command:

    1. navigate to the folder C:\Temp (you may assume it exists, you should create it on your own computer if it doesn't). Note: Linux and Mac users should pick some other temporary folder, such as /tmp.
    2. create a file within that folder called "Example.txt". This file may be empty, or it may contain some text.
    3. create another file, which name should not be hardcoded, but should be accepted as an argument to the batch file

    My attempt:

    Code (Text):
    cd /Users/tmp

    echo "New file" >Example.txt
     
    I cant really understand task number 3. Can anyone help me?
     
  2. jcsd
  3. Sep 8, 2013 #2

    CWatters

    User Avatar
    Science Advisor
    Homework Helper

    If you have a command file (say Print.bat) that is designed to perform an operation on another file (eg print it) then you don't want to have to edit the command file every time you want to print a different file. You want to be able to tell it the name of the file to print when you actually run it. To do this you put the name of the file you want printed in the command line when you run it. This is called "passing an argument" or "passing a parameter".

    Google "passing arguments into a batch file" without the quotes.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Help with terminal project in Mac
  1. Need help in a project (Replies: 1)

  2. Help with the Project (Replies: 1)

  3. Help in school project (Replies: 2)

  4. School Project help (Replies: 2)

Loading...