Page 1 of 1

Help! I sux @ Unix

Posted: Fri Mar 19, 2004 6:47 pm
by Nitrofox125
Well actually I have a few different questions here.

1. How do I use wildcards in a delete? I have lines like this say:
VALUES('-1','2','Whee','OMG');
And I want them to end up like this:
VALUES('2','Whee','OMG');
With the -1 gone. However I can't just do a normal find and replace, because the -1 changes with every line. what program can do this and what is the command/way to do this?
The closest i got was in VI
:s/VALUES('*',/VALUES(/g but that didn't work.

2. How to list only directories in unix ls?
What I'm looking for is the unix equivilent to
dir /s /ad /s *

Thanks
:D

Posted: Fri Mar 19, 2004 9:36 pm
by Instig8
study up on your regular expressions.

and, for god's sake, read the man or info pages.

i don't know much about vi. maybe try

Code: Select all

:s/VALUES('[*]',/VALUES(/g
and, i always use

Code: Select all

ls -lap
(aliased to l) to list directories.

Posted: Fri Mar 19, 2004 11:02 pm
by Nitrofox125
I looked at the man pages for ls and it didn't really give me what I wanted... :
Thanks for that other info though...

I was thinkin maybe like :s/VALUES('[0-9]',/...... or something might work..

Re: Help! I sux @ Unix

Posted: Sat Mar 20, 2004 1:59 am
by R e v
Nitrofox125 wrote:2. How to list only directories in unix ls?
'ls' does not support listing only directories.

To show all directories try the following:
find -type d -maxdepth 1

If you are new to *nix, or anything for that matter, www.google.com is your friend.

Posted: Sat Mar 20, 2004 7:32 am
by Admiral LSD
sed I think might be capable of doing what you want. You'll have to read up on the syntax though as I don't know it off the top of my head.

Posted: Sun Mar 21, 2004 9:20 am
by Cuda68-2
http://unix.about.com/library/glossary/ ... tution.htm

It also has the valid wildcard characters defined for *nix.

Posted: Sun Mar 21, 2004 11:12 am
by DCrazy
This finds all directories below this one:

find . -type d

If you want to make this command available in a short form (for example, if you want to be able to call "lsdir" and get this result) put the following line in a file called .bashrc in your home (~) directory.

alias lsdir='find . -type d'

Posted: Tue Mar 30, 2004 9:00 pm
by Instig8
If you don't want subs, maybe use:

alias lsdir='ls -lp |grep /'

Now, when you type lsdir you only see directories. A million ways to skin a cat.

Posted: Tue Mar 30, 2004 11:07 pm
by Nitrofox125
Lol... find . -type d -maxdepth 1 worked quite well. Thanks all!

Posted: Thu Apr 01, 2004 10:55 am
by R e v
Nitrofox125 wrote:Lol... find . -type d -maxdepth 1 worked quite well. Thanks all!
you're welcome