- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Search and replace in unix(Replace colon with ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 09:18 AM
тАО01-07-2004 09:18 AM
Should look like:
sam 111
dave 232
==========unix command below=======
# cut -d: -f1,3 /etc/passwd > output
sam:111
dave:232
==============
Not modifying /etc/passwd . Just sending the output to another file
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 09:23 AM
тАО01-07-2004 09:23 AM
SolutionRgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 09:27 AM
тАО01-07-2004 09:27 AM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
# cut -d: -f1,3 /etc/passwd |awk -F: '{print $1 " " $2}' > output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 09:29 AM
тАО01-07-2004 09:29 AM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
Use
sed 's/:/ /g' /etc/passwd > output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 09:32 AM
тАО01-07-2004 09:32 AM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
there are always lots of ways to do things :-)
awk -F: '{print $1 " " $3}' < /etc/passwd > output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 09:33 AM
тАО01-07-2004 09:33 AM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
awk -F: '{print $1 " " $2}' output
-Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 09:34 AM
тАО01-07-2004 09:34 AM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
I guess greate minds think alike.
You just type faster than I.
-Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-07-2004 02:28 PM
тАО01-07-2004 02:28 PM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
cut -d: -f1,3 /etc/passwd | tr -s ":" " "
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2004 02:37 AM
тАО01-08-2004 02:37 AM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
perl -pi -e 's|\:| |g' output
to update the "output" file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2004 02:45 AM
тАО01-08-2004 02:45 AM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
Hi,
Please find below command, this helps. But don't do it on original passwd file.
#sed 's/:/ /g' passwd > passwd.new
Best of luck
Shahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2004 02:46 AM
тАО01-08-2004 02:46 AM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
or shorter, but more cryptic
# perl -aF: -ple'$_="@F[0,2]"' /etc/passwd
Enjoy, Have FUN! H.Merijn [ Who thinks -i is extremely dangerous on /etc/passwd ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2004 06:09 AM
тАО01-08-2004 06:09 AM
Re: Search and replace in unix(Replace colon with space in /etc/passwd)
#!/usr/bin/sh
while IFS=: read login pw uid gid etc
do
echo $login $uid
done < /etc/passwd > output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-08-2004 06:43 AM
тАО01-08-2004 06:43 AM