Cutting only the 1st column data | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

Cutting only the 1st column data

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-20-2013
abhi_123 abhi_123 is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 26 June 2014, 12:49 AM EDT
Posts: 39
Thanks: 2
Thanked 0 Times in 0 Posts
Cutting only the 1st column data

Hi All,

I having a data file which consists of 20cr records in it. The 1st column is year field which consist of year in format 200809 and fields are seperated with ^.
How do i trim it to 2008 in file and save it in a quick time as there are many records so that i can use the file for loading into database.
Thanks

Sample File format:

Code:
"200809^1235566^^asghagsdg^212^N^"


Last edited by Scott; 06-21-2013 at 03:11 AM.. Reason: Code tags
Sponsored Links
    #2  
Old 06-20-2013
RavinderSingh13 RavinderSingh13 is offline
Registered User
 
Join Date: May 2013
Last Activity: 1 September 2014, 2:14 AM EDT
Location: Chennai
Posts: 527
Thanks: 174
Thanked 92 Times in 89 Posts
Hello Abhi,

Could you please let me know the deired Output so that it will be easier for us to solve it.


R. Singh
Sponsored Links
    #3  
Old 06-20-2013
abhi_123 abhi_123 is offline
Registered User
 
Join Date: Jun 2008
Last Activity: 26 June 2014, 12:49 AM EDT
Posts: 39
Thanks: 2
Thanked 0 Times in 0 Posts
sample output


Code:
"2008^1235566^^asghagsdg^212^N^"

Only the 1st columns is changed from 200809 to 2008.
Thanks

Last edited by Scott; 06-21-2013 at 03:10 AM.. Reason: Code tags
    #4  
Old 06-20-2013
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Advisor  
The Tutor
 
Join Date: Jun 2008
Last Activity: 9 April 2014, 1:31 AM EDT
Location: INDIA, Bangalore
Posts: 2,049
Thanks: 16
Thanked 106 Times in 102 Posts
try


Code:
 
awk -F"^" '{$1=2008;OFS="^";print $0}'  filename

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
Compare 2 files and match column data and align data from 3 column asnandhakumar Shell Programming and Scripting 5 10-16-2012 09:58 AM
Summing up rows data regarding 1st column AAWT Shell Programming and Scripting 4 04-10-2012 08:18 AM
[Q] cutting from one column and pasting to another mcampos7 UNIX for Dummies Questions & Answers 9 10-31-2011 04:32 PM
Cutting the first 8 chars of a 2nd column cassj UNIX for Dummies Questions & Answers 9 03-28-2008 11:22 AM
Need help recurrently cutting single column file jacks Shell Programming and Scripting 3 02-09-2008 04:46 PM



All times are GMT -4. The time now is 03:35 AM.