LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-16-2001, 05:17 PM   #1
eboats
LQ Newbie
 
Registered: Oct 2001
Posts: 11

Rep: Reputation: 0
programming questions


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
 
Old 10-16-2001, 05:48 PM   #2
isajera
Senior Member
 
Registered: Jun 2001
Location: San Antonio, TX
Distribution: distro? what's a distro?
Posts: 1,635

Rep: Reputation: 45
triple post - http://www.linuxquestions.org/questi...&threadid=7605


... i can't believe i beat kewpie to both of these .
 
Old 10-16-2001, 08:13 PM   #3
eboats
LQ Newbie
 
Registered: Oct 2001
Posts: 11

Original Poster
Rep: Reputation: 0
little help

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.
 
Old 10-16-2001, 10:08 PM   #4
isajera
Senior Member
 
Registered: Jun 2001
Location: San Antonio, TX
Distribution: distro? what's a distro?
Posts: 1,635

Rep: Reputation: 45
lessee...

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.
 
Old 10-17-2001, 02:15 AM   #5
eboats
LQ Newbie
 
Registered: Oct 2001
Posts: 11

Original Poster
Rep: Reputation: 0
thx

Thank you for your help, I will see how much it actually helps me out. Hopefully this should work well.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
questions about programming... efm Programming 12 11-29-2005 01:58 PM
2 programming questions hk_michael Programming 4 02-01-2005 12:02 AM
HELP!!!! 5 questions about linux programming jormuocu Programming 4 01-30-2005 05:17 PM
Programming Questions/Poll name_in_use450 Programming 10 07-15-2004 08:09 PM
programming questions eboats Linux - General 19 10-22-2001 05:15 PM


All times are GMT -5. The time now is 12:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration