How would I write this script in linux?

How would I write this script in linux? Topic: How to write a t in script
July 17, 2019 / By Archie
Question: a. Change the cwd (current working directory) to home directory b. Prompt user to enter a name of directory to create. c. Create the directory that user entered. d. Create files : test1.txt, test2.txt and test3.txt within the newly created directory. e. Change the current working directory to the newly created directory. f. Prompt the user to enter a name for the new file. g. Create the new file as entered by the user. h. Issue command “tree” on the directory created in step “c”. at least give me a basic outline i just don't understand what to do
Best Answer

Best Answers: How would I write this script in linux?

Trina Trina | 1 day ago
not much of a scripter. but it should go something like; ... cd ~ #Change CWD to user home. echo "What do you want to call your new directory?" read dirname #accepts user input, saves to dirname. mkdir $dirname #creates dirname in CWD touch $dirname/test1.txt touch $dirname/test2.txt touch $dirname/test3.txt #Creates 3 desired text files?? cd $dirname #Change CWD to new DIR. echo "New file name?" #Request new file name from user. read filename #Accept user input, save to filename touch $filename tree $dirname #Not sure what you're aiming for here. #Perhaps this command instead? ls exit 0 #Stops script. I only wrote my first ever script yesterday, so I could be completely wrong, Not running Linux atm so can't debug, pls let me know how you go! Good Luck! Steegs [email protected]
👍 250 | 👎 1
Did you like the answer? How would I write this script in linux? Share with your friends

We found more questions related to the topic: How to write a t in script

Trina Originally Answered: Linux - Which user is granted extensive powers in UNIX?Linux to administer the system?
1): B - root 2): B - exit (must be lowercase) 3): Must be : ... and redirect the process output to that file? A - >

Sallie Sallie
save script file name as homework.sh, #!/bin/bash # change dir to home (these are comments...) cd ~ # prompt a name echo "Enter the dir name to be created: " read name # create dir mkdir $name # create null files touch $name/test1.txt $name/test2.txt $name/test3.txt # change dir cd $name # promt for file echo "Enter the filename: " read filename # create null file touch $filename # run tree tree
👍 110 | 👎 -7

Nicolette Nicolette
cd $HOME echo Enter directory name read DIR mkdir $DIR touch test1.txt touch test2.txt touch text3.txt cd $DIR echo Enter a file name read FN touch $FN tree ../$DIR Type all the above things a file with name say zzz Give permissions chmod u+x zzz To run this script ./zzz
👍 110 | 👎 -15

Lynette Lynette
That IS the basic outline. It doesn't really get any simpler than that without giving you the actual commands. Basically, each one of those points should be its own seperate command. Just take it step by step, look up each command in your book or whatever your class is using to teach you.
👍 110 | 👎 -23

Lynette Originally Answered: How can you get contracted to write a novel or movie script?
They will find you if you have a good track record. If you have no history in that field you will find that no one will want to offer a contract.

If you have your own answer to the question how to write a t in script, then you can write your own version, using the form below for an extended answer.