LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-06-2023, 11:20 AM   #1
eawedat
LQ Newbie
 
Registered: Aug 2012
Posts: 11

Rep: Reputation: Disabled
How to print /etc/passwd in different output?


i would like to write a script that prints /etc/passwd as this output:

root daemon bin sys …
x x x x
0 1 1 2
root daemon bin sys

first line has all user accounts in same row
second line has all encrypted passwords (x) in same row
third line has all user ids in same row
and etc…
 
Old 02-06-2023, 11:32 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,792

Rep: Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002
Quote:
Originally Posted by eawedat View Post
i would like to write a script that prints /etc/passwd as this output:

root daemon bin sys …
x x x x
0 1 1 2
root daemon bin sys

first line has all user accounts in same row
second line has all encrypted passwords (x) in same row
third line has all user ids in same row
and etc…
Great...we know what you would like to do. Now can you show us what you've done to accomplish your goal? We are happy to help you, but you need to show your own efforts; we aren't going to write your scripts for you, or do your homework for you.
 
Old 02-06-2023, 02:26 PM   #3
maw_walker
Member
 
Registered: Jul 2021
Posts: 119

Rep: Reputation: Disabled
Quote:
Originally Posted by eawedat View Post
i would like to write a script that prints /etc/passwd as this output:
second line has all encrypted passwords (x) in same row
Sorry, pet peeve: passwords in Linux are stored HASHED, not "encrypted". Two completely different things. Also, there are no passwords in /etc/passwd, the password hashes are stored in /etc/shadow.

rant over.
 
2 members found this post helpful.
Old 02-06-2023, 11:11 PM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,885
Blog Entries: 1

Rep: Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872Reputation: 1872
Bash has arrays which could be useful to solve this.
 
Old 02-07-2023, 07:44 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,011

Rep: Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194Reputation: 3194
As TB0ne said, happy to assist once you identify where it is you are stuck and what you have tried?
 
  


Reply

Tags
bash, linux, shell



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] .new files for /etc/passwd, /etc/shadow, etc. uiopqwerty Slackware 3 07-20-2020 06:45 AM
[SOLVED] Legacy Account in /etc/passwd, /etc/shadow and/or /etc/group lalit singhania Linux - Newbie 4 06-07-2012 06:33 AM
Problem with /etc/passwd and /etc/passwd- files linuxravindra414 Linux - Newbie 2 01-15-2011 05:17 AM
[SOLVED] /etc/passwd- & /etc/shadow- & /etc/group- Mr. Alex Linux - Newbie 1 12-31-2010 05:19 AM
/etc/passwd, /etc/shadow, /etc/group? Educate me :)! nutnut Linux - General 4 06-11-2005 07:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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