tags:

views:

1154

answers:

4

Hi,

I have a CSV file like this:

SUPPORT 07/30/2008-10:59:54 Eastern Daylight Time
123     07/03/2009-08:56:42 Eastern Daylight Time
DC321   07/10/2009-20:16:56 Eastern Daylight Time

where the date is an entire column. how can i remove the entire "Eastern Daylight Time" part of the string with awk?

+1  A: 

So you want only the 1st and 2nd column? If yes

awk '{print $1"\t"$2}' file.csv
piotrsz
actually, the date is all in one column.the file has two columns total, so i need to "filter" out this second column.
If it is a csv, separated by commas, you probably want $1","$2 but yeah. +1.
Nick Presta
Why the downvote?
piotrsz
+3  A: 

Based on your comment in piotrsz's answer, this is how you could remove the EDT part:

awk '{gsub("Eastern Daylight Time", "");print}' file.csv
Nick Presta
That looks like it. I just was in the middle of asking DCrawmer to replace his commas in the data to be sure.
Pinochle
+2  A: 

I don't know awk, but a sed version would be

sed "s/ Eastern Daylight Time//" file.csv
David Sykes
This follows my general rule of trying sed first, then awk, then a full compiled language.
T.E.D.
A: 

using just the shell

while read -r line
do
    case "$line" in
        *Eastern* )
            echo "${line%%Eastern*}"
            ;;
        *) echo "${line}"
    esac
done < "file"