Manipulating the etc/passwd file with sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Manipulating the etc/passwd file with sed
# 8  
Old 11-30-2009
Quote:
Originally Posted by Pauline mugisha
Thnx. That is easier
Easier than what?!

Easier than

Code:
awk '{ print $1, $6}' /etc/passwd

I hardly think so!

---------- Post updated at 12:30 AM ---------- Previous update was at 12:01 AM ----------

My apologies.

There is an error in the original awk:

Code:
awk -F: '{ print $1, $6}' /etc/passwd

# 9  
Old 11-30-2009
Quote:
Originally Posted by Pauline mugisha
Thnx. That is easier
sed is not the appropriate tool for this job, although it can do it, but the code it produce is ugly and hard to read due to extensive (or abusive) use of regex. Use awk and break the file rows into pieces using delimiters. That's the easiest way it can be.
# 10  
Old 12-01-2009
I agree with ghostdog. In situations where there is a clear field oriented format awk solutions usually provide more straightforward code. I disagree about the supposed ugliness and hard to read regex (and I do not get the abuse bit), but I like regex. Smilie
# 11  
Old 12-01-2009
Quote:
Originally Posted by Scrutinizer
I disagree about the supposed ugliness and hard to read regex (and I do not get the abuse bit), but I like regex. Smilie
you can take it that i mean hard to read and forget about the word "ugliness". regex is sure powerful, but too much of it in one place makes your code "hard to read". Its like reading an essay with words encoded in numbers. that's what i meant.
# 12  
Old 12-01-2009
Ofcourse awk is better. Wanted to know how to use sed as an option
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Manipulating xyz file with awk-if-else or sed

Hi forum, I am really hoping somebody can please help me here. I have a dataset in xyz format, with longitude as x, latitude as y and data readings as z. eg. 0 90 -8 1 90 23 2 90 -4 etc etc etc What i am looking to do is format the data so that x and y are untouched, however in... (2 Replies)
Discussion started by: shlam16
2 Replies

2. Shell Programming and Scripting

Manipulating a variable using sed (solved)

Hi, My variable has value as this: tvar1="bool_risk_enabled" Boolean "true" Now I need to replace this true with false. Which is the best way to do this? Can we do this with sed command? Please help me. ---------- Post updated at 05:23 PM ---------- Previous update was at 05:00 PM... (2 Replies)
Discussion started by: pravintse
2 Replies

3. Shell Programming and Scripting

need help on manipulating a file

Hi, I need a shell/command to achieve this task. I've a delimited unloaded file from oracle in a scrambled format as shown below with many blank lines in it, I'm just trying to tailor it in a format that would be compatible to view and load it to a IDS db. Here is the problem ... (1 Reply)
Discussion started by: divak
1 Replies

4. Shell Programming and Scripting

Manipulating a file

Hi everybody, I need an urgent help with a BASH script. I have file which contains (besides the other data) the lines with the following structure identified by with keyword PCList: <PARAMETER NAME="PCList" TYPE="LIST_STRUCTURE" MODEL="{,}" ... (1 Reply)
Discussion started by: sameucho
1 Replies

5. Shell Programming and Scripting

Manipulating a header file using awk or sed

Hi Guys, Is there a simple way of doing the below. Available<spaces>Assigned<spaces>Maximum<spaces>Maximum<spaces>Page<spaces>Total <spaces>Used<spaces>Pct<spaces>Max. Pct<CR> Space<spaces>Capacity<spaces>Extension<spaces>Reduction<spaces>Size<spaces>... (8 Replies)
Discussion started by: eo29
8 Replies

6. Shell Programming and Scripting

sed script to manipulate the /etc/passwd file

Hi. Can anybody help me with a script to extract usernames, shell and home_directory from the /etc/passwd file. I am stuck (2 Replies)
Discussion started by: Pauline mugisha
2 Replies

7. Shell Programming and Scripting

manipulating Fields in file using SED

Hi, I have two issues: I have one file say file1.dat and its over 3GB. It contains pipe delimited fields. The first line in the file is the header field which tells the column names etc. and from second line it's the data fileds with pipe delimited. Something like below: ... (5 Replies)
Discussion started by: rkumar28
5 Replies

8. UNIX for Dummies Questions & Answers

Help!! manipulating file

Hi all, I need help manipulating the file below. Here is what I needed to do. First, I have to replace INSUPD to DELETE. Then I need to change the content of the file around by flipping the contents in the file from the bottom to the top (start from "CMD") How should I attack this? Here... (2 Replies)
Discussion started by: sirrtuan
2 Replies

9. Solaris

Manipulating File

Help...please. I have a log that contains Warning Authentication Failed: User GHDT88998HS doesn't exit: The User GHDT88998HS could not be found Mar 22, 2008 5:22:22AM com.hometel.ttm.auth.userlogin. about maybe a thousand entries failed user acct message How can I grab just the username... (2 Replies)
Discussion started by: rivendell500
2 Replies

10. Shell Programming and Scripting

Manipulating awk $variables using sed?

I have been searching around the forums here trying to find a solution to my problem but not getting anywhere but closer to baldness. I have a 20 column pipe "|" seperated text file. The 14th variable doesnt always exist, but will have the format of YYYYMM or YYYY if it does. I need to take... (2 Replies)
Discussion started by: r0sc0
2 Replies
Login or Register to Ask a Question