We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,519 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Need help using tr and cut file to another file

Hello I have something for my scripting class I am assigned to do, I can not figure out who to do these set of instructions, I beleive i am supposed to use the tr command, he has 'cut file | tr ":" " " ' on the board. i am very confused, the instructions go as following

"Cut the login name field(#1) and the display name field (#5) from the /etc/passwd file and redirect the output to a file name cutpw

cut the login name field (#1) and the terminal field (#2) from the output of the who command and redirect the output to a file name cutwho

Join the cutpw and cutwho files on the login name fields and redirect the output inot a file named joinfile"

2
Contributors
1
Reply
8 Hours
Discussion Span
1 Year Ago
Last Updated
2
Views
geoffy0404
Junior Poster in Training
51 posts since Nov 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Have you tried playing around with the commands?

$ tr ':' ' ' < /etc/passwd | head -n 5
root x 0 0 root /root /bin/tcsh
bin x 1 1 bin /bin /sbin/nologin
daemon x 2 2 daemon /sbin /sbin/nologin
adm x 3 4 adm /var/adm /sbin/nologin
lp x 4 7 lp /var/spool/lpd /sbin/nologin

or

$ cut -d':' -f 3 < /etc/passwd | head -n 5
0
1
2
3
4

The more you play with the tools the better you will understand them. If you have trouble with any of the commands just type man command into the shell. For example, to learn more about the cut command you would do

$ man cut
L7Sqr
Practically a Posting Shark
849 posts since Feb 2011
Reputation Points: 253
Solved Threads: 155
Skill Endorsements: 7

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.2817 seconds using 2.67MB