Help - Search - Members - Calendar
Full Version: Writing a Script with requirements
Linuxhelp > Support > Programming in Linux
bubbawoo
I am VERY new to Linux and am trying to do this extra credit for a class. I have tried researching and there is so much information, I am just not sure how to make this work. This is what I have been tasked to do:

You will need to write a script named "getQuote.sh" (must be executable) that meets the following requirements:

1. Check if the file "quote1" exists in your home directory.
2. If the file "quote1" does not exist in your home directory, copy it from "/some/crazy/file" to your home directory.
3. Print the contents of the file "~/quote1" to the screen.
4. Compress the file "~/quote1" using the gzip utility AFTER requirement 3.

I have tried entering the following lines for the script, but it doesn't work:

#!/bin/bash

if [ -f ~/.quote1 ]; then
cp ~/.quote1 ~/.quote1.old
ls -alh ~/.quote*
gzip ~/quote1
fi

Please help!!!
michaelk
~/.quote1 I do not know if the . in the file name is a typo but in this context it means hidden which I doubt is what you want.

This is your assignment and not ours so we are not going to write it for you. I/we will answer specific questions. These guides should hellp a bit.
tldp.org/LDP/Bash-Beginners-Guide/html/chap_07.html
tldp.org/LDP/Bash-Beginners-Guide/html/sect_07_01.html
bubbawoo
Thank you for the response. I did not presume that anyone would write the assignment for me, but simply asked for guidance, since there is so much information out there. Linux is definitely not beginner friendly and it is difficult to find the right information when there is so much of it and you have no idea what to look for. Again, thanks for the information. I will take a look at it and hope for the best.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2017 Invision Power Services, Inc.