LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

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:42 PM   #2
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
1) look up regular expressions. (grep)
2) at the command line, type "man ls"
3) also at the command line, type "man chmod"
4) "esc", "ZZ" - entering ":q!" will exit without saving any changes
5) do your own homework
 
Old 10-16-2001, 08:27 PM   #3
eboats
LQ Newbie
 
Registered: Oct 2001
Posts: 11

Original Poster
Rep: Reputation: 0
more on this

Well this is material I am learning. I need to be able to do these things for the class, and the "teacher" isn't any help. I figured I would ask the experts out there for help. Once I find out the correct commands then I can understand them. The guy that "teaches" this class is like a mail order professor from another country. He can't speak english, and teaches unix on the blackboard. I am sure you can imagine my frusteration. Any other help with these you could provide would be much appreciated.
 
Old 10-16-2001, 08:29 PM   #4
eboats
LQ Newbie
 
Registered: Oct 2001
Posts: 11

Original Poster
Rep: Reputation: 0
other stuff

I also found the following from another forum.

1) :3,9s/bad/good/g

2) Technically, I don't think there is a SINGLE command to do this in the Unix manifest.. A series of commands
piped through each other will do it for you. If you use this frequently, you may want to make a script file of the pipe.

3) Set the directory to be world (or group, depending on visibility) readable, and set all files in the directory to be
owner readable only. You will need the chmod command for this. In the spirit of Unix, man chmod, aka
RTFM. You may also find the umask command helpful. YMMV.

4) esc{esc*}:wq!

5)
man regexp (hint: look at the meaning of the '.' and '*' characters
man ksh (or whatever shell you're using) (hint: look at the cp command, ie cp -R /d1 /d2)
man grep (hint: look at piping the result of grep for 'hot' through grep for 'cold')
man vi (hint: open file, command mode, ":/test")
man ls (hint: ls -a, and the funkiness that is the .profile file)

Do these look correct? Also will just the man chmod command work for 3?
 
Old 10-16-2001, 08:31 PM   #5
eboats
LQ Newbie
 
Registered: Oct 2001
Posts: 11

Original Poster
Rep: Reputation: 0
more

If you guys really have some beef about helping me out with this, can you direct to a board with people who can, or a place where I can find the answers to these seemingly difficult questions?
 
Old 10-16-2001, 09:36 PM   #6
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally posted by isajera
5) do your own homework
hey now, we should play nice here...

as for your questions, yeah some of that, that you dug up looks right. some of your questions won't get a definite answer cause of the nature of them, especially the programming specifics. you should direct those to the programming forum. as for the vi editor, you might want to check out this site for a quick tutorial on it and what you can do with it: http://www.eng.hawaii.edu/Tutor/vi.html

Last edited by trickykid; 10-16-2001 at 09:41 PM.
 
Old 10-16-2001, 09:44 PM   #7
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
Quote:
Originally posted by trickykid


hey now, we should play nice here...

yeah, yeah.... i'll be nice. but try to keep the double/triple posting down to a minimum . check the programming forum post - i'll see what i can get answered. you might want to close the other two tricky.
 
Old 10-16-2001, 09:50 PM   #8
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
unfortunantly, i can only close forums in my forum that i am moderator of... i wish i was god and could elsewhere. hey maybe that should be the privalege once i reach 2000 posts..

yeah i know we all hate double or more posts.... but actually most of his question was not even related to programming so i am gonna leave this one open.
 
Old 10-16-2001, 10:15 PM   #9
eboats
LQ Newbie
 
Registered: Oct 2001
Posts: 11

Original Poster
Rep: Reputation: 0
more

Sorry about the 3x post. I am new here, and didn't know the conduct, and I didn't know where it should go or where it was most likely to be answered. It seems I have gathered enough information from you, and the sites you have given me to answer the first 4 questions. Is the info I have on 5 accurate, if not where can I get more accurate information, or can you give me some.
 
Old 10-16-2001, 10:20 PM   #10
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
you're forgiven

check my post in the programming forum - i answered that fifth one for the most part.

BTW, welcome to linuxquestions
 
Old 10-17-2001, 02:07 AM   #11
eboats
LQ Newbie
 
Registered: Oct 2001
Posts: 11

Original Poster
Rep: Reputation: 0
another ?

You guys must know a lot about unix. How proficient are you in other languages, and which ones are you good at. Right now I am only good at C++
 
Old 10-17-2001, 02:50 AM   #12
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
Re: another ?

Quote:
Originally posted by eboats

You guys must know a lot about unix.


lol - thx, but no need to butter anyone up here. everyone on this site came here because, at some point, they were completely stumped by one thing or another.

if you come back here much, you'll more or less get to know who can help with what. generally, it's just the sheer number of people who come through here that ends up getting an answer. eventually, you'll just be browsing through the forums... notice someone has a prob... "hey... i know how to fix that...", and *wham* - next thing you know you have 560 posts and you're having strange semantic arguments with a guy named acid_kewpie...
 
Old 10-17-2001, 03:34 AM   #13
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you want to argue about semantics?!

I'm NOT a guy!
I'm NOT a bloke!
I'm NOT a geezer!

I'm a boy, and nothing more.

thankyou.

now go tie up some cows.
 
Old 10-17-2001, 11:24 AM   #14
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
hey now... we don't just tie up cows in texas, i like to watch the tumbleweeds blow across the streets in my spare time... hehe.

ok, no more making coments about others or i am gonna close this thread down.
 
Old 10-17-2001, 04:10 PM   #15
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
Quote:
Originally posted by trickykid

ok, no more making coments about others or i am gonna close this thread down.
lol... darn. i was just starting to have fun ... boys can be so sensitive...
 
  


Reply



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 On
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 Programming 4 10-17-2001 02:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:56 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration