Command Line Question
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. Thanks for your help! |
We don't do homework for you, but if you post your current code and where you're getting stuck we can offer advice.
|
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. Again, I appreciate the help. |
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? Edit: What is the name of the book you're using? |
Quote:
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. |
All times are GMT -5. The time now is 12:09 PM. |