LinuxQuestions.org
Visit Jeremy's Blog.
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 01-14-2010, 09:36 AM   #1
tastie
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Rep: Reputation: 0
grep all values other than encrypted password from /etc/shadow file


I would like to grep all values other than encrypted password from /etc/shadow file. Could someone please help me?
For example,each line consists of 8 fields separated with :/
The only thing that I want not to print out is the contents between first : and second : (encrypted password)
Can someone please please help me???

userid:$1$lnfkdkkwkqHkDa:13064:0:999:7:::

Last edited by tastie; 01-15-2010 at 08:24 AM.
 
Old 01-14-2010, 09:42 AM   #2
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
Code:
cut -d ":" -f 2 --complement /etc/shadow
Regards,

Alunduil
 
Old 01-14-2010, 10:30 PM   #3
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
@tastie

Kindly modify your thread title as follows, it'll help you fetch more answers, and others to search this thread !

Quote:
grep all values other than encrypted password from /etc/shadow file
 
Old 01-14-2010, 10:59 PM   #4
Smartpatrol
Member
 
Registered: Sep 2009
Posts: 196

Rep: Reputation: 38
...

Last edited by Smartpatrol; 03-11-2010 at 09:58 PM.
 
Old 01-15-2010, 12:08 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
No, post #2 is correct; OP wants everything EXCEPT field 2 (passwds).
 
Old 01-15-2010, 08:20 AM   #6
tastie
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Original Poster
Rep: Reputation: 0
complement?

So, should it be
cut -d ":" -f 2 /etc/shadow
???
or cut -d ":" -f 2 --complement /etc/shadow ?? doesn't complement converts my selection?? so it would just print out passwords?
 
Old 01-15-2010, 08:51 AM   #7
devnull10
Member
 
Registered: Jan 2010
Location: Lancashire
Distribution: Slackware Stable
Posts: 572

Rep: Reputation: 120Reputation: 120
Assumes there is always 8 fields...
Code:
awk -F ':' '{print $1,$3,$4,$5,$6,$7,$8}' < /etc/shadow
 
Old 01-15-2010, 09:03 AM   #8
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
With the cut you want complement because if you're just selecting column 2 you'll get nothing but the passwords. By complementing the selection of column 2 you are saying everything but the passwords.

Regards,

Alunduil
 
  


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
pass variable from one shell script into another shell script xskycamefalling Programming 9 10-03-2009 01:45 AM
help with execute mulitple shell script within shell script ufmale Programming 6 09-13-2008 12:21 AM
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM

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

All times are GMT -5. The time now is 03:05 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