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 > 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
unable Insert data from .dat file to .xls can anybody help me kreddy2003 Shell Programming and Scripting 1 05-28-2008 05:33 AM
How to insert new line in the data file using the script Sona UNIX for Dummies Questions & Answers 2 08-22-2006 01:17 AM
find the position in a file and insert the data there isingh786 HP-UX 5 04-11-2006 09:31 PM
how to insert data in database based on text file? forevercalz Shell Programming and Scripting 9 12-20-2005 11:40 PM
sed, insert data from a file to another? ctcuser Shell Programming and Scripting 4 05-03-2005 01:43 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 10-23-2006
babu@shell babu@shell is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 12
Question help me to to insert data

hi,
am new to unix can any one help me to insert data to afile to a specified
column.

ie to an output file with csv format i should insert some data to 2,3,4 fileds and the data in those fields should move to next fields

eg:
output file

asd,12,12,12,12,1,2,1,1,1,1,1
mnmn,1,12,1,1,1,112,12,1,1,1


insert data

after asd 33,44
after mnmn 55,66


ie required o/p

asd,33,44,12,12,12,12,1,2,1,1,1,1,1
mnmn,55,66,1,12,1,1,1,112,12,1,1,1
  #2 (permalink)  
Old 10-23-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
Code:
nawk -F, -v OFS=',' -v asd='33,44' -v mnmn='55,66' '$1 == "asd" || $1 == "mnmn" '$1 == "asd" || $1 == "mnmn" {$1= $1 OFS (($1==asd) ? asd : mnmn)}1' myFile.txt

Last edited by vgersh99; 10-23-2006 at 07:45 AM..
  #3 (permalink)  
Old 10-23-2006
babu@shell babu@shell is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 12
can u exp the code
  #4 (permalink)  
Old 10-23-2006
babu@shell babu@shell is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 12
hi
i am getting an error

as below

insert: line 1: syntax error near unexpected token `('
insert: line 1: `nawk -F, -v OFS=',' -v asd = '33,44' -v mnmn = '55,66' '$1 == "asd" || $1 == "mnmn" '$1 == "asd" || $1 == "mnmn" { $1= $1 OFS (( $1 == asd ) ? asd : mnmn )}1' myFile.txt'
  #5 (permalink)  
Old 10-23-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
sorry - bad copy/paste:
Code:
nawk -F, -v OFS=',' -v asd='33,44' -v mnmn='55,66' '$1 == "asd" || $1 == "mnmn"  {$1= $1 OFS (($1==asd) ? asd : mnmn)}1' myFile.txt
  #6 (permalink)  
Old 10-23-2006
napolayan napolayan is offline
Registered User
  
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
Quote:
Originally Posted by babu@shell
hi,
am new to unix can any one help me to insert data to afile to a specified
column.

ie to an output file with csv format i should insert some data to 2,3,4 fileds and the data in those fields should move to next fields

eg:
output file

asd,12,12,12,12,1,2,1,1,1,1,1
mnmn,1,12,1,1,1,112,12,1,1,1


insert data

after asd 33,44
after mnmn 55,66


ie required o/p

asd,33,44,12,12,12,12,1,2,1,1,1,1,1
mnmn,55,66,1,12,1,1,1,112,12,1,1,1
clarify a few things...the data u'll be inserting will be in a file? n the no. of rows in that file is equal to the no. of rows in the file to which u wanna insert?

i mean, if u have 10 rows in the file u want to change, u want to insert data into all the 10 rows n in a sequential manner?
  #7 (permalink)  
Old 10-23-2006
napolayan napolayan is offline
Registered User
  
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
hi vgersh99


can u plz explain ur code? for a newbie, its difficult to understand the latter half of the code..
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 01:00 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