The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
grep unix.com with google



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #8 (permalink)  
Old 11-30-2009
scottn scottn is offline Forum Staff  
Moderator
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,611
Quote:
Originally Posted by Pauline mugisha View Post
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 (permalink)  
Old 11-30-2009
Registered User
 

Join Date: Sep 2006
Posts: 2,604
Quote:
Originally Posted by Pauline mugisha View Post
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 (permalink)  
Old 12-01-2009
Registered User
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,259
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.
  #11 (permalink)  
Old 12-01-2009
Registered User
 

Join Date: Sep 2006
Posts: 2,604
Quote:
Originally Posted by Scrutinizer View Post
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.
  #12 (permalink)  
Old 12-01-2009
Registered User
 

Join Date: Nov 2009
Posts: 20
Ofcourse awk is better. Wanted to know how to use sed as an option
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0