The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
korn shell script to keep history of same file watson2000 UNIX for Dummies Questions & Answers 2 10-09-2006 10:38 PM
Read file - korn shell alienET Shell Programming and Scripting 5 04-06-2005 02:22 PM
file activity (open/closed) file descriptor info using KORN shell scripting Gary Dunn UNIX for Dummies Questions & Answers 3 06-07-2004 01:54 PM
Read a file and replace a value- Bourne and Korn shell kenix Shell Programming and Scripting 3 09-20-2002 09:25 AM
Changing korn shell script text Menu colors? darthur UNIX for Dummies Questions & Answers 6 01-20-2002 07:15 PM

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 02-27-2006
riteshm riteshm is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 1
Changing a CSV file in Korn shell

Hi All,

Please can someone help me how I can read a CSV file with 10 columns and remove the 2nd, 4th, 6th, 8th column and build the new output file. Script to be done in Korn shell.

File contains data like bnt, lb2, lb3, vnw, lb4, lb5, bst, lb6, lb7, vgw (multiple rows)

Output file should contain bnt, lb3, lb4, bst, lb7, vgw (multiple rows)

Thanks in advance.

-RiM

Last edited by riteshm; 02-27-2006 at 12:39 PM.. Reason: for clear understanding of the requirement
  #2 (permalink)  
Old 02-27-2006
rajeeb_d rajeeb_d is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 37
Try this

awk -F "," '{for(i=1;i<=NF;i++) if(i!=2 && i!=4 && i!=6 && i!=8) if(i<NF) printf("%s,",$i); else printf("%s%s",$i,"\n");}' <filename>
  #3 (permalink)  
Old 02-27-2006
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
cut -d, -f1,3,5,7,9- file1 > file2
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:57 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