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 Answers: How would I write this script in linux?
Trina | 1 day ago
not much of a scripter. but it should go something like;
#Change CWD to user home.
echo "What do you want to call your new directory?"
#accepts user input, saves to dirname.
#creates dirname in CWD
#Creates 3 desired text files??
#Change CWD to new DIR.
echo "New file name?"
#Request new file name from user.
#Accept user input, save to filename
#Not sure what you're aiming for here.
#Perhaps this command instead?
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!
👍 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
save script file name as homework.sh,
# change dir to home (these are comments...)
# prompt a name
echo "Enter the dir name to be created: "
# create dir
# create null files
touch $name/test1.txt $name/test2.txt $name/test3.txt
# change dir
# promt for file
echo "Enter the filename: "
# create null file
# run tree
👍 110 | 👎 -7
echo Enter directory name
echo Enter a file name
Type all the above things a file with name say zzz
chmod u+x zzz
To run this script
👍 110 | 👎 -15
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