insert dummy values in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting insert dummy values in a file
# 1  
Old 02-10-2012
insert dummy values in a file

Hey guys, i have a file a.txt and i need to insert a dummy data into it as per the below pattern..

bash:
Code:
cat a.txt
1234,34
3434,45
4545,56
3434,56

Now i need the file in the below pattern
Code:
1234,34,a0001,C_01
3434,45,a0002,C_02
4545,56,a0003,C_03
3434,56,a0004,C_04

here the count of file is 4, but in real the count is in crores.

Need you help as in how to insert the dummy data in ascending order as mentioned above.

Thanks in advance..!!! Smilie

Last edited by Franklin52; 02-11-2012 at 09:08 AM.. Reason: Please use code tags for data and code samples, thank you
# 2  
Old 02-10-2012
Something like this?
Code:
awk '{$0=$0",a"sprintf("%04d",NR)",C_"sprintf("%02d",NR)}1' file

# 3  
Old 02-11-2012
Thanks mahn... It's working..!!!

what if i need the same values in the new columns???

i mean in the last two coloumns...!!!

---------- Post updated 02-11-12 at 11:35 AM ---------- Previous update was 02-10-12 at 08:16 PM ----------

hey guys,

one more thing.. i need to run this file on daily basis... though i need to make sure that i continue with the next series.

like yesterday if the last line was 3434,56,a0004,C_04 then today if i again run the same command, it continues with 3343,343,a0005,C_05.

The next time i run this command,I need to continue the series..

Kindly suggest how it can be done..
# 4  
Old 02-11-2012
if you want to add new rows in current file or new one? In current file, you should count the current rows and add new column value; if not, should reference the last file's row count.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert values into a file 0 as per the date wise

Hi The file contains 12 months of date and less than 12 months of data I want to display if date filed less than 12 months of data I want to insert a value amount 1 to amount4 0 and dates as well. 12345|Date|cntry|amount1|amount2|amount3|amoun4... (2 Replies)
Discussion started by: jagu
2 Replies

2. UNIX for Dummies Questions & Answers

Default values for positional parameters - dummy question I think

Hi, Sorry for a dummy question I believe. I am just wanting to know how do I assign a default $1 argument if one is not provided. At the moment, I am doing something like below: arg1="${1:-foo}"And then I check $arg1 in case/esac. I am just wondering if there is a way for me to simply do... (3 Replies)
Discussion started by: newbie_01
3 Replies

3. Shell Programming and Scripting

Insert values

HI Guys, I have a data in a file in the below format 45783 23457 23556 54584 Now i want to convert this data into the below format reader='45783' or reader='23457' or reader='23556' or reader='54584' Please help how to convert as i am applying loop but not able to get the data... (6 Replies)
Discussion started by: jaituteja
6 Replies

4. Shell Programming and Scripting

how to Insert values in multiple lines(records) within a pipe delimited text file in specific cols

this is Korn shell unix. The scenario is I have a pipe delimited text file which needs to be customized. say for example,I have a pipe delimited text file with 15 columns(| delimited) and 200 rows. currently the 11th and 12th column has null values for all the records(there are other null columns... (4 Replies)
Discussion started by: vasan2815
4 Replies

5. Shell Programming and Scripting

How do i find the first number in each line and insert dummy string into the missing columns?

Hi, I have one input file with the following content: MY_inpfile.txt Aname1 Cname1 Cname2 1808 5 Aname2 Cname1 1802 47 Bname1 ? 1819 22 Bname2 Cname1 1784 11 Bname3 1817 9 Zname1 Cname1 1805 59 Zname2 Cname1 Cname2 Cname3 1797 27 Every line in my input file have a 4 digit... (5 Replies)
Discussion started by: Szaffy
5 Replies

6. Shell Programming and Scripting

Korn shell program to parse CSV text file and insert values into Oracle database

Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database. I need to write the korn shell program on Red Hat Enterprise Linux server. Oracle database is 10g. (15 Replies)
Discussion started by: shellguy
15 Replies

7. Shell Programming and Scripting

hw to insert array values sequentially in a file

Hi All :), I am very new to unix. I am requiring ur help in developing shell script for below problem. I have to replace the second field of file with values of array sequentially where first field is ValidateKeepVar <File> UT-ExtractField 1 | &LogEntry &Keep(DatatoValidate)... (3 Replies)
Discussion started by: rohiiit.sharma
3 Replies

8. Shell Programming and Scripting

How to insert values in 1st occurance out of two occurance in a file

Hi I have a file which contains the following two lines which are same But I would like to insert the value=8.8.8.8 in the 1st occurance line and value=9.9.9.9 in the 2nd occurance line. <parameter name="TestIp1" value=""> <parameter name="TestIp1" value=""> Please suggest (1 Reply)
Discussion started by: madhusmita
1 Replies

9. AIX

How to insert dummy columns

Hi My requirement is as follows, I have a input feed coming for X as A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P; any other feed coming from Y is as ... (2 Replies)
Discussion started by: smolgara
2 Replies

10. UNIX for Advanced & Expert Users

insert pipe in file to separate values

hi all... i need your help, because i donīt know what to do... i have a flat file like this: B065200512312004123111010000061451 000021853 B065200512312004123111020000621907 000417802 B065200512312004123111030000005214 000005861 B065200512312004123111040000120133 000088448 and i need... (5 Replies)
Discussion started by: DebianJ
5 Replies
Login or Register to Ask a Question