1833380 Members
3395 Online
110052 Solutions
New Discussion

echo

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

echo

How can I echo the passwd file and redirect into a file, where all of the users are on the 1st line of the file, separated by spaces?

Im stuck
UNIX IS GOOD
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor
Solution

Re: echo

Hi:

# perl -naF":" -e 'push(@a,$F[0]);END{print "@a\n"}' /etc/passwd > myfile

Regards!

...JRF...
Michael Mike Reaser
Valued Contributor

Re: echo

Or, using awk:

awk -F: '{printf("%s ",$1)}END{print}' < /etc/passwd > myfile
There's no place like 127.0.0.1

HP-Server-Literate since 1979
Tingli
Esteemed Contributor

Re: echo

cat /etc/passwd | awk -F: '{print $1}' | tr "\n" " "
Dennis Handly
Acclaimed Contributor

Re: echo

echo $(awk -F: '{print $1}' /etc/passwd) > myfile

>Tingli: cat /etc/passwd | awk -

No need to use cat(1) here.