need some grep help

need some grep help

Post by Dogg » Tue, 09 Jul 2002 09:27:05



For the life of me, I can't find a grep command that can do this.

I want to pipe the usernames that is in the passwd file to a text
file. Can grep do that for me.

doggy

 
 
 

need some grep help

Post by Tony Curti » Tue, 09 Jul 2002 09:34:25


>> On 7 Jul 2002 17:27:05 -0700,

> For the life of me, I can't find a grep command that can
> do this.  I want to pipe the usernames that is in the
> passwd file to a text file. Can grep do that for me.

(grep is the wrong tool for this, you need something that
can extract pieces of lines not just find them; and you
mean "redirect" not "pipe".)

    getent passwd | awk -F: '{print $1}'

is one way to do it.

hth
t

 
 
 

need some grep help

Post by Petr Swedoc » Tue, 09 Jul 2002 09:46:45



> For the life of me, I can't find a grep command that can do this.

> I want to pipe the usernames that is in the passwd file to a text
> file. Can grep do that for me.

You want awk.  Man awk.  

awk -F: '{print $1}' /etc/passwd > filename

Peace,

Petr

 
 
 

need some grep help

Post by Andreas K?h? » Tue, 09 Jul 2002 09:47:26


Submitted by "Doggy" to comp.unix.admin:

Quote:> For the life of me, I can't find a grep command that can do this.

> I want to pipe the usernames that is in the passwd file to a text
> file. Can grep do that for me.

> doggy

cut -d: -f1 < /etc/passwd > textfile

--
Andreas K?h?ri
--------------------------------------------------------------
Stable, secure, clean, free:  www.netbsd.org

 
 
 

need some grep help

Post by Andreas K?h? » Tue, 09 Jul 2002 10:06:44


Submitted by "Petr Swedock" to comp.unix.admin:


>> For the life of me, I can't find a grep command that can do this.

>> I want to pipe the usernames that is in the passwd file to a text
>> file. Can grep do that for me.

> You want awk.  Man awk.  

I read that as "You want awk, man. awk."

Quote:

> awk -F: '{print $1}' /etc/passwd > filename

Shorter with cut.

--
Andreas K?h?ri
--------------------------------------------------------------
Stable, secure, clean, free:  www.netbsd.org

 
 
 

need some grep help

Post by Isaac Azathot » Tue, 09 Jul 2002 13:06:21



>Submitted by "Doggy" to comp.unix.admin:
>> For the life of me, I can't find a grep command that can do this.

>> I want to pipe the usernames that is in the passwd file to a text
>> file. Can grep do that for me.

>> doggy

>cut -d: -f1 < /etc/passwd > textfile

The "<", here is superfluous and misleading, viz:

User Commands                                              cut(1)

NAME
     cut - cut out selected fields of each line of a file

SYNOPSIS
     cut -b list [ -n ] [ file ... ]
     cut -c list [ file ... ]
     cut -f list [ -d delim ] [ -s ] [ file ...  ]

 
 
 

need some grep help

Post by Edward Ned Harve » Tue, 09 Jul 2002 23:11:59




>>Submitted by "Doggy" to comp.unix.admin:
>>> For the life of me, I can't find a grep command that can do this.

>>> I want to pipe the usernames that is in the passwd file to a text
>>> file. Can grep do that for me.

>>> doggy

>>cut -d: -f1 < /etc/passwd > textfile

> The "<", here is superfluous and misleading, viz:

How is it misleading?  I think it's pretty clear.

How about this instead:
cat /etc/passwd | cut -d: -f1 > usernames.txt

 
 
 

need some grep help

Post by yt.. » Wed, 10 Jul 2002 02:17:29



> Submitted by "Petr Swedock" to comp.unix.admin:

>>> For the life of me, I can't find a grep command that can do this.

>>> I want to pipe the usernames that is in the passwd file to a text
>>> file. Can grep do that for me.

>> You want awk.  Man awk.  
> I read that as "You want awk, man. awk."

>> awk -F: '{print $1}' /etc/passwd > filename
> Shorter with cut.

Ubiquitous with awk.

-----.

--
"Hell, rocket science isn't even rocket science"
--A NASA rocket scientist, undernet, circa 1996

 
 
 

1. grep sTerm * | grep -v grep ???

in .bashrc

alias r='ps ax | grep $1 | grep -v grep'

this works from the command line but doesn't work from the bashrc.
Apparently there's a syntax problem.

...and

. filename

where can I read about this commad that is found in bash and sh
scripts?  I searched the bash and one or two other man pgs to no
avail.  Thanks gurus.

--


2. Shootout at the XP Corral

3. tail | grep | grep | grep

4. Apache / NetScape

5. PLEASE HELP A NEWBIE: grep doesn't grep

6. Race in fs/proc/generic.c:make_inode_number()

7. grep help needed

8. How to perform simple tcp port mapping?

9. Help! need an 'exclude' grep

10. Grep bug? Help in double-checking needed.

11. need help with grep

12. grep,egrep,fgrep help needed

13. Need help on using find + grep