ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
I have a few questions that I would like answered. If any of you can help me please do.
1)Using vi, in the command mode, what command will change all the occurrences of the word "bad" in lines 3-9 to "good"?
2)Which ONE command will list files in my current directory, SORTED so the most recently accessed file is last in the list?
3)I don't want everyone else seeing the contents of my home directory, but I want them to still be able to change their current directory to my home directory. I need the commands to do this.
4) Using vi to modify my file called h1.c I have already modified the file. I am in the insert mode and I want to save the file and exit. I need the commands that need to be done in the order in which they should occur.
5)I also need to write a shell script to do the following.
-List all the files in my current directory having 2 or more characters in their filenames.
-Recursively copy a directory d1 to another directory d2, assuming both d1 and d2 are under root directory.
-Prints the lines in file f1 that have both the words hot or cold in them, assuming f1 is in my current directory
-Edit the file test.txt using the vi editor, starting from where the word "test" first occurs, assuming test.txt in my current directory
-Redefine the command ls to be able to list hidden files
Come on now guys. You appearently know much more then I do. I need some help with that last one. I am taking unix now, and the "teacher" is actually a TA who doesn't know much. He also is from asia, so he can't teach it very well since it is real hard to understand him. The worst part is we are taught on a freakn' blackboard, and not a computer. I know you have the knowledge, so I am asking you to please share the answer of my 5th question with me.
ok, you can redefine ls two different ways:
1. alias ls='ls -a' : -a is the option to print out all files. you can get rid of the alias using "unalias"
2. most systems use the LS_OPTIONS enviromental variable. changing it is system dependant tho. most will use the "set" command, but you might not have permission to change it.
ls --sort=time : this will print out the file in the directory in the order of the time they were created. you might also want to toss in the -l option (ls -l --sort=time) so that the times will be printed too.
grep "hot" "cold" f1 - grep is short for "global regular expression print". it's a sed program.
cp -r d1 d2 : the -r option is for recursive copying
vi +/test test.txt : this will open test.txt with the cursor on the first instance of "test" in the file
that's what i remember off the top of my head. to get a list of the files with two characters or more, you're going to need to pipe ls into a sed command. i think it's going to be something like /../, but i haven't used sed in a really long time, so i don't remember exactly.