![]() |
|
|
grep unix.com with google
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Our Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||
|
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
|
|
|||
|
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.
|
|
|||
|
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.
![]() |
|
|||
|
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.
|
|
|||
|
Ofcourse awk is better. Wanted to know how to use sed as an option
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| manipulating Fields in file using SED | rkumar28 | Shell Programming and Scripting | 5 | 06-10-2009 03:58 PM |
| Help!! manipulating file | sirrtuan | UNIX for Dummies Questions & Answers | 2 | 07-16-2008 06:18 PM |
| Manipulating File | rivendell500 | SUN Solaris | 2 | 03-25-2008 10:52 PM |
| Manipulating a text file | komalkg | Shell Programming and Scripting | 6 | 06-24-2007 07:15 AM |
| Manipulating output file | mariner | UNIX for Advanced & Expert Users | 1 | 04-20-2005 09:26 AM |