The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
calculating sum of fields in a file dsravan Shell Programming and Scripting 4 01-03-2008 01:00 PM
Searching for fields in a file c2b2 UNIX for Dummies Questions & Answers 4 12-12-2006 11:40 AM
help me to count no of fields in a file babu@shell Shell Programming and Scripting 7 10-31-2006 01:36 AM
Extarcting particular fields from a file sendhilmani123 Shell Programming and Scripting 2 04-26-2006 10:24 AM
How to add fields in a file bjorb Shell Programming and Scripting 2 10-13-2005 09:11 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-29-2008
praveen_b744 praveen_b744 is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 49
Exclamation How to work with fields of a csv file?

I need to insert data into a perticular field of a csv file, lets say second field.

Can any one help me to do this?
I found that we can do it with sed. can any one guide me to accomplish this?
thanks in advance.
  #2 (permalink)  
Old 01-29-2008
pt14 pt14 is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 28
awk 'BEGIN {FS=","}
{
print $1","x","$2
}' x=$var filename.csv
  #3 (permalink)  
Old 01-29-2008
praveen_b744 praveen_b744 is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 49
Exclamation

cant I have any command line operation?

can we do this with 'sed'?
  #4 (permalink)  
Old 01-29-2008
pt14 pt14 is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 28
sed -n 's/\(^.\)*,\(.*\)/\1"whatever you want to insert here"\2/p'
  #5 (permalink)  
Old 01-29-2008
pt14 pt14 is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 28
sed -n 's/\(^.\)*,\(.*\)/\1"whatever you want to insert here"\2/p' filename.csv
  #6 (permalink)  
Old 01-29-2008
praveen_b744 praveen_b744 is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 49
thanks for reply,

what do '(' ')' these represent? can we use [] braket instead of () ?
  #7 (permalink)  
Old 01-29-2008
pt14 pt14 is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 28
() helps you group patterns. \(^.\) is represented by \1. Similarly \(.*\) is represented by \2

You cannot use [] instead of ()
Closed Thread

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 On




All times are GMT -4. The time now is 08:33 AM.


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