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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Recently ran into a problem during one of my homework assignments regarding sed/awk that really stumped me. Sorry if it's a little long, any advice or partial solutions would help me greatly. Here is the question:
Suppose that -l was the only option available for the ls utility and that the sort utility had no options available at all. Consider generating a long listing sorted by owner (3rd column). Type a single command-line that includes sed and/or awk to produce a long listing sorted by owner (that is, fed by an "ls -l" command-line pipe). Don't use any options other than "-l" to the "ls" command and none at all for the sort command. BIG HINT: To do this, first process the long listing of the current working directory so that the owner of each file (column 3) is duplicated at the front of each line (being careful to do this in such a way that you can remove it again, later in the pipe). Further, pipe these results to a process to delete the first line (the header) of the listing, sort the results (which will be sorted by owner as you duplicated that column at the front of each line), and finally, remove the owner column (that you previously added to the front of each line). ANOTHER HINT: you can assume that all user names consist only of lower-case letters, but you don't know their individual widths). Your final result will be a long listing sorted by owner. Be sure not to somehow end up with any extra space at the front of each line (the original ls -l listing did not contain any leading spaces)! What you end up with should look EXACTLY like the ORIGINAL long listing, except sorted by owner. Make sure the column widths are not damaged (don't produce ragged columns, and you can't assume that all data in every column will just happen to have the same width... for example, the owner names could be of different lengths - I mention this so that you can make sure that what works for you will also work for me). You might have to make some fake data with different owners in the 3rd column to practice with before you report your final solution. Make sure your final output doesn't look like it has been re-formatted (the columns should all line up properly, as in the original)."
sorry guy, I do not really understand what do you expect now.
Do you have any part implemented? Usually in such cases I will not use piped chain of tools but one single script (awk, perl or whatever you prefer)
The hint was fairly complete... and if you read anything about awk you would know that the $0 field is the entire line... all that is left is what to use as a separator between the sort key and the original line.