Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hi i was wondering if someone could help me with this assignment of mine, im completely lost.
1.
Create a shell script called usage.bash that requires at least two input arguments. If the script is run with less than two arguments, the script should print out a USAGE statement with a non-zero exit code. Otherwise, it should print out two separate lines stating:
Your first argument was ___ .
Your second argument was ___ .
2.
Create a shell script called newest.bash that takes two filenames as input arguments and prints out the name of the newest file (i.e. the file with the newest last modified date). If two arguments are not passed, display a Usage statement and exit with a non zero status.
3.
Create a shell script called bigger.bash that takes two arguments, the first argument is a number, and the second argument is a filename. The shell script should indicate if the file's (argument 2) size is BIGGER, SMALLER, or EQUAL to the number (argument 1) provided. If two arguments are not passed, display a Usage statement and exit with a non zero status.
4.
Create a shell script called permissions.bash that takes a filename as an input argument and determines if the file is a normal file, or directory, then prints out the permissions of the file in one of the following forms:
You have read and execute permissions to the directory /etc.
You have read and write permissions to the file ~/.bashrc.
You have read and write and execute permissions to the file permissions.bash.
If one argument is not passed, display a Usage statement and exit with a non zero status.
5.
Create a shell script called fivesecs.bash that starts the command /labs/bash/count.sh and lets it run for 5 seconds, then terminates it. Note, you will need to background the task and then use the kill command. If any arguments are passed, display a Usage statement and exit with a non zero status.
hi i was wondering if someone could help me with this assignment of mine, im completely lost.
1. Create a shell script called usage.bash that requires at least two input arguments. If the script is run with less than two arguments, the script should print out a USAGE statement with a non-zero exit code. Otherwise, it should print out two separate lines stating:
Your first argument was ___ .
Your second argument was ___ .
2. Create a shell script called newest.bash that takes two filenames as input arguments and prints out the name of the newest file (i.e. the file with the newest last modified date). If two arguments are not passed, display a Usage statement and exit with a non zero status.
3. Create a shell script called bigger.bash that takes two arguments, the first argument is a number, and the second argument is a filename. The shell script should indicate if the file's (argument 2) size is BIGGER, SMALLER, or EQUAL to the number (argument 1) provided. If two arguments are not passed, display a Usage statement and exit with a non zero status.
4. Create a shell script called permissions.bash that takes a filename as an input argument and determines if the file is a normal file, or directory, then prints out the permissions of the file in one of the following forms:
You have read and execute permissions to the directory /etc.
You have read and write permissions to the file ~/.bashrc.
You have read and write and execute permissions to the file permissions.bash.
If one argument is not passed, display a Usage statement and exit with a non zero status.
5. Create a shell script called fivesecs.bash that starts the command /labs/bash/count.sh and lets it run for 5 seconds, then terminates it. Note, you will need to background the task and then use the kill command. If any arguments are passed, display a Usage statement and exit with a non zero status.
Sorry, we are not going to do your homework for you. We will HELP you...that means, you post what you've written, and explain where you're stuck. Otherwise, there are thousands of scripting tutorials you can find on Google that can help you: http://tldp.org/LDP/abs/html/
Posting a homework question verbatim, without doing any of the work is plain lazy and pointless. YOU are taking the class...if you don't learn, what's the point? If you're genuinely having problems, tell your teacher, and they'll work with you, and we're here to help too. But you have to show some effort.
# usage statement
# by student name
# created on 11/10/2011
if [ $# -lt 2 ]
then
echo "USAGE: $0 argument"
this is where im at so far
Ok..why did you stop? You've completed the first step, so now add a second check to output something if you have two arguments. Then you're done with step one.
Think about step 2. Read the man pages on the find command, and pay attention to the -mtime/atime/ctime switches
Think about step 3. Do an "ls -l", and grab the file size from it to compare against the argument given.
Think about step 4. Do an "ls -l"...look at the string output, which will tell you what it is, and you can parse the permissions from there.
Think about step 5. Read the man page on the sleep command.
Doesn't look like you're stuck, it looks like you stopped trying.
Sorry to disagree with a Guru TB0ne but I still think that the stat command will be more useful for part 2 that the find command. The time switches on the find command are to search for files when you know something about their times. In the exercise, he is gives the filenames as arguments and needs to extract the time details. He might need to use find to get the full path to the files though.
Sorry to disagree with a Guru TB0ne but I still think that the stat command will be more useful for part 2 that the find command. The time switches on the find command are to search for files when you know something about their times. In the exercise, he is gives the filenames as arguments and needs to extract the time details. He might need to use find to get the full path to the files though.
No apologies necessary, trappa01. There's always more than one way to do things...I was just trying to give the OP a nudge.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.