Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 05-21-2012
Registered User
 
Join Date: May 2012
Location: Dallas
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Shell Script help for Quotation Delimited File

I need help extracting a column in a file separated by quotations. I would like to extract the first column of data and write it to a flat text file. EXAMPLE of data:


Code:
"c6e181396a1100ba19c53a6757a845c4","2012-05-18","email"
"70879000563753bb9051b4ab8df43ac4","2012-05-18","email"
"8dc50039efcb069cc0a9c40cc9015068","2012-05-18","email"
"9a0ce897cdb52a18fa5c76e3309def16","2012-05-20","email"

Any help would be greatly appreciated.

Nick

Last edited by Scott; 05-21-2012 at 05:16 PM.. Reason: Please use code tags
Sponsored Links
    #2  
Old 05-21-2012
Registered User
 
Join Date: Jul 2008
Location: NY
Posts: 203
Thanks: 13
Thanked 39 Times in 38 Posts

Code:
awk -F, '{print $1}' infile > outfile


Code:
cut -d , -f 1 infile > outfile

The Following User Says Thank You to 47shailesh For This Useful Post:
hlosukwakha (05-21-2012)
Sponsored Links
    #3  
Old 05-21-2012
Registered User
 
Join Date: May 2012
Location: Dallas
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
excellent! worked perfect. Another step. How may I take out the quotes?
    #4  
Old 05-21-2012
Registered User
 
Join Date: Jul 2008
Location: NY
Posts: 203
Thanks: 13
Thanked 39 Times in 38 Posts

Code:
awk -F\" '{print $2}' infile > outfile

OR
Code:
cut -d \" -f 2 infile > outfile

Sponsored Links
    #5  
Old 05-21-2012
Registered User
 
Join Date: May 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Try piping it through the tr command:

Code:
tr -d '"'

Sponsored Links
    #6  
Old 05-21-2012
Registered User
 
Join Date: May 2012
Location: Dallas
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
wow great! Thanks for the help. All fixed up!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to convert a space delimited file into a pipe delimited file using shellscript? nithins007 Shell Programming and Scripting 7 09-25-2011 05:33 AM
Searching a delimited Key value pairs in shell script ANK Shell Programming and Scripting 4 09-28-2010 01:04 AM
convert a pipe delimited file to a':" delimited file priyanka3006 Shell Programming and Scripting 6 05-26-2009 10:53 AM
Need help with shell script for chekking a column in txt file - pipe delimited ravi0435 UNIX for Dummies Questions & Answers 12 01-02-2009 03:31 PM
Converting Tab delimited file to Comma delimited file in Unix charan81 Shell Programming and Scripting 22 01-20-2006 08:24 AM



All times are GMT -4. The time now is 01:34 PM.