LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-05-2016, 03:40 PM   #1
kcraig4
LQ Newbie
 
Registered: Dec 2016
Posts: 1

Rep: Reputation: Disabled
College Linux course help.


Hello, i am currently taking a intro to Linux course at my local community college. We have a final coming up and im freaking out about it. It's rather simple to most but not so much for me. I try my best to read and practice as much as i can without life interfering. I struggle extremely hard trying to figure this stuff out but it just doesn't click. I developed my own study guide for the final, that is composed of some questions and example scripts. I was wondering if anyone could help me with some questions or even push me in the right direction. Final is on Wednesday and i am becoming desperate, which is why i am here . Here is my study guide and some example scripts. Ill put the questions i am really struggling with.

1.) How do you set up an alias?
ex :
Code:
alias TODAY='date +%Y%m%d%H%M%S%N'
2.) Write a script that will email all logged in users fortune.
Code:
#!/bin/bash

F=$ who | sort | uniq | awk '{print $1}'
for x in $F
do fortune | mail | $print $1
done
3.) Create and html header and footer environmental variable. (I will then be asked to do something with that) (Very confused on this one)

4.) Create a log file

5.) Parse the etc password
Code:
awk -F:'$7 == :/bin/bash" {print $1}' /etc/passwd
6.)IFS (not entirely sure what he wants us to do with this)

7.) Write 3 short scripts that demonstrate sequence, iteration, and selection.

Sequence :
Code:
#!/bin/bash
      for i in 1 2 3 4 5
      do
         echo "Welcome $i times"
      done
Iteration :
Code:
for (( expr1; expr2; expr3 ))
      do
          command 1
          command 2
          ..
      done
Selection :
Code:
PS3 = "Enter the space shuttle to get more information:"
      select shuttle in columbia endeavour challenger discovery atlantis enterprise pathfinder
      do
         echo "$shuttle selected"
      done
8.) Write a script that displays the current lines of uptime
Code:
uptime >> up.log
      cat up.log | tail -5
9.) Write a script that calculates and equation he will give in class.

10.)And he gave us this code that he says will be a trick question give the output (code will be slightly different on test.

Code:
Let x=0
Let y=10
While [ $x -lt $y ] 
	Do
	Echo -n *
x-$((x+1))
Done
Echo *


./while1 | wc -c

I know its alot to ask and not sure if any can or will help me. But at least i can try. I appreciate all of your time. Thanks
 
Old 12-06-2016, 01:32 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 6,903
Blog Entries: 3

Rep: Reputation: 3585Reputation: 3585Reputation: 3585Reputation: 3585Reputation: 3585Reputation: 3585Reputation: 3585Reputation: 3585Reputation: 3585Reputation: 3585Reputation: 3585
Probably best to take them one at a time. Start a thread for each question showing how far you have gotten yourself and explain what approach you are trying. We can't do your homework for you and, especially since this is prep for a test, it wouldn't help you if we did. My recommended strategy is to try the easy ones first and then do the ones that look harder, not take them in sequence.
 
Old 12-06-2016, 06:19 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,256

Rep: Reputation: 2206Reputation: 2206Reputation: 2206Reputation: 2206Reputation: 2206Reputation: 2206Reputation: 2206Reputation: 2206Reputation: 2206Reputation: 2206Reputation: 2206
Quote:
Originally Posted by Turbocapitalist View Post
Probably best to take them one at a time. Start a thread for each question showing how far you have gotten yourself and explain what approach you are trying. We can't do your homework for you and, especially since this is prep for a test, it wouldn't help you if we did. My recommended strategy is to try the easy ones first and then do the ones that look harder, not take them in sequence.
make google your friend, and write them questions in the search box. You'd be surprised by the results you might find.
Because I know I can read how to do it in theory, but until I get hands on, it doesn't stick with me.

You don't know about IFS, type IFS in google and you'll see you'll find out what it is for, then you can go on to coming up with something that puts it to use.

Remember, google or any search engine uses key words to search as well. So be sure to always slap in the word "Linux" at the end.

for example:
One of your questions is:
4.) Create a log file

Search box entry: Create a log file Linux
One result is:

HowTo: Save The Output Of A Linux/Unix Command To A File


Question:
How can an absolute or relative path be used when creating a log file, and Why?
(as you see there is always more questions when answering questions, sometimes)


A little hint when dealing with BASH Scripts. If you can do it on the Command Line (CLI) then it will work in BASH. So before you go wasting a lot of time writing a script thinking your code will work. Test it out first in the CLI. That way, too. You can play around with your code and see how it works. Getting instant results. Use your errors to figure out what you're doing wrong. Goggle it. The exact error if you cannot figure it out.

the word 'Google' is synonymous with the word "search"

Code:
Let x=0
Let y=10 What is wrong with them two declarations? 

While [ $x -lt $y ]  There is something wrong with this line
	Do            something wrong here too
	Echo -n “*”   and here
x-$((x+1)) <-- what is that? Will that even work? Test it out on your CLI.
Done  something wrong here as well
Echo “*”  as well as here


./while1 | wc -c   This is the only thing that would even work, provided that your code would
work. Which it will not. You'd be throwing errors all over the place if you were to put this in
a BASH Sctipt.

Last edited by BW-userx; 12-06-2016 at 07:34 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux in College rob_zak Linux - General 6 01-03-2006 12:51 PM
Linux at college... alpha2zero Linux - Enterprise 8 12-26-2005 05:43 PM
College Linux? Occulum Linux - Software 7 08-09-2005 12:42 PM
Anyone using College Linux...I need help!! 68 Stepside Linux - Newbie 1 10-17-2003 01:31 AM
College Linux ? TuxToaster Linux - Distributions 1 06-01-2003 05:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration