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 am new student taking a class in Linux. I am having trouble with a couple of questions currently.
1) I have to run a command that shows all of /etc/passwd starting with line 20.
2) I made a file that contains several different numbers. In this file there are two '42' entries. I need help with the command that would combine those two '42' entries into one.
I'm not looking for anyone to do my homework for me. My point is this: I understand the significance in understanding what I am doing and not looking for an easy grade. I am taking on IT as a career and cheating isn't going to help me. I need help and thought this was the best forum for it.
To answer your question, there really isn't any code. The questions are all something I can type into the command line to make it do something. This is a beginning Unix/Linux class. I can't find the answer to my two questions online or in my book.
With the second question, it specifically asks for a command that consolidates two '42' entries within a file into one entry.
In the first scenario, you need to pipe the /etc/passwd file through a command that strips the first 19 lines from the output. There are numerous ways to accomplish this, but you may want to take a close look at the tail command.
As for the second scenario, you would need to seek out the two "42" entries and then somehow combine them. By "entry", do you mean an entire line containing the number 42? How is the output supposed to look?
there really isn't any code. The questions are all something I can type into the command line to make it do something. This is a beginning Unix/Linux class. I can't find the answer to my two questions online or in my book.
I am certain the instruction or labwork would have covered these tasks, or at the very least suggested what the right tool for the job is supposed to be.
pseudo-code perhaps? you know,
if
this is true,
do this.
else
do that
fi
Every shell script starts off with a bang, that, at least is better than "isn't any code".
For the first problem you can use `sed' with a range selection. Use the -n option and the print command, or select what you don't want to see and use the delete command.
You will find plenty of examples using used on the web.
I don't follow what you are asking about 42. It's supposed to be The Answer to the Ultimate Question of Life, the Universe, and Everything. If they ask about 420, start worrying.
I imagine that what you really need is a guide to where to look for information.
Start by looking at at "info coreutils" for a rundown of the basic maintenance-level programs available. These, plus grep, sedawk, and built-in shell features, will cover the majority of your shell-processing needs.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.