Linux - NewbieThis 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
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.
I need to write a bash script that prints the values of the following data of
Example
My username : dalux
My homedirectory : /home/dalux
My hostname : localhost. localdomain
My current dir. : /home/dalux/courses
My shell : /bin/bash
My search path : /usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin
And all the data to the right of the colon shall be read read from the enviroment of my Linux box.
I have no idea how to do this. Can anyone help me? I need a complete explanation.
I need to write a bash script that prints the values of the following data of
Example
My username : dalux
My homedirectory : /home/dalux
My hostname : localhost. localdomain
My current dir. : /home/dalux/courses
My shell : /bin/bash
My search path : /usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin
And all the data to the right of the colon shall be read read from the enviroment of my Linux box.
I have no idea how to do this. Can anyone help me? I need a complete explanation.
Thanks
Code:
#!/bin/bash
# This program is designed to tell you what user you are currently:
whoami
# I'm assuming you only want to see what your /home area ("~") is:
# This should print the long-line, human readable version of your home:
ls -ldh ~
# This shows you your host name by reading the file that contains it:
cat /etc/HOSTNAME
# This shows your "present working directory", i.e. "where am i?"
pwd
# First, the stuff in the `` tells you what shell you are in
# Second, since you wanted it with the path, i used "which" for that.
# The "which" command shows you the full path of shell commands:
which `echo $0`
# This prints the environment variable $PATH, which is your command path.
echo $PATH
I have a gut feeling this is homework, so forum rules say we should not solve it for you. Indeed it wouldn't be fair. But this is such a simple homework assignment, surely any basic bash tutorial will have the answers in the first few pages, try: http://tldp.org/LDP/abs/html/
and probably this will help too: http://rute.2038bug.com/index.html.gz
And all the data to the right of the colon shall be read read from the enviroment of my Linux box.
I think this is the relevant part of your homework: you have to become familiar with environment variables. The command set gives you them all. Anyway, as H_TeXMeX_H pointed out a good tutorial should give all the answers, as well as your course notes and your teacher. Try to search the answers deep inside this chapter of the Advanced Bash Scripting Guide.
I need to write a bash script that prints the values of the following data of
Example
My username : dalux
My homedirectory : /home/dalux
My hostname : localhost. localdomain
My current dir. : /home/dalux/courses
My shell : /bin/bash
My search path : /usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin
And all the data to the right of the colon shall be read read from the enviroment of my Linux box.
I have no idea how to do this. Can anyone help me? I need a complete explanation.
Thanks
I think you should complte your homework by yourself, Mr Google is enough for you.
you could get good guide in here: http://www.freeos.com/guides/lsst/
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.