Help with incrementing data in some field


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with incrementing data in some field
# 1  
Old 11-02-2012
Help with incrementing data in some field

Hi
I have the below set of lines , i need to duplicate these lines 1000 times, also eevrytime when it is incremented , it should increment the one in Blue color.
130400030000010000200001
130400030000010000200002
140050030000010000200005A

eg:
130400030000010000200001
130400030000010000200002
140050030000010000200005A

for next time ,it should be
130400030000010000300001
130400030000010000300002
140050030000010000300005A

so on till 1000 times.

how it can be done with shell script ?
# 2  
Old 11-02-2012
Code:
for i in `seq -f "%04g" 1 1000`
do
echo "130400030000010$i00001
130400030000010$i00002
140050030000010$i00005A"
done

# 3  
Old 11-02-2012
it dint work.
# 4  
Old 11-02-2012
I did my test on an ubuntu distrib.

So you may need to adapt the code depending on your own OS.

Just stating "it didn't work" does not really help us to help you.

Try this:
Code:
awk 'BEGIN{c=0;while (++c<=1000) { print "130400030000010" c "00001" RS "130400030000010" c "00002" RS "140050030000010" c "00005A"}}'

# 5  
Old 11-02-2012
your code
Code:
for i in `seq -f "%04g" 1 1000`
do
  echo "130400030000010$i00001
  130400030000010$i00002
  140050030000010$i00005A"
done

works fine , but ill not display the numbers which are after $i .it ll only display till $i.

Last edited by Franklin52; 11-05-2012 at 03:11 AM.. Reason: Please use code tags for data and code samples
# 6  
Old 11-02-2012
Please copy/paste exactly what is in your script and/or what you typed .
by the way did you give a try to the awk code ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Pivoting data based on a header field

Hi Team, Could you please help me with the below scenario. I have a file which is in the below format. Zipcode,001,001f,002,002f,003,003f,004,004f,005,005f,006,006f,007,007f 0050, ,0, ,0, ,0, ,1,*,7, ,7, ,7 0060, ,0, ,0, ,7, ,0,*,7, ,0, ,0 Would need the output as below. First field... (1 Reply)
Discussion started by: saj
1 Replies

2. Shell Programming and Scripting

Field matching in two data files

Hello, I am looking to output all of the lines from file2 whose 11th field is present in the first field in file1. Then the second field from file1 should be appended as such: file1: 2222 0.35 4444 0.25 5555 0.75 file2: col1 col2 col3 col4 col5 col6 col7 col8 col9 col10 1111 col1 col2... (4 Replies)
Discussion started by: palex
4 Replies

3. Programming

Field delimited data to XML

Hi, We need to produce a XML file based on a record/field delimited data file. At this point we could just script something out but I would like to ask the community what would be the best choice of programming language to do this, in terms of performance of execution, and in terms of complexity... (9 Replies)
Discussion started by: Indalecio
9 Replies

4. Shell Programming and Scripting

Look up data in another file and return another field

I'm a newbie to perl and not much of a coder in general, but I must use it at my new task at work. I have two text files that are several hundred MBs large. I need to pull in data from a column in file 2 into file 1. Basically, file 2 is the lookup table and I can key off the unique id column that... (3 Replies)
Discussion started by: zam171
3 Replies

5. Shell Programming and Scripting

Replace a data in a field if that does not contain a particular pattern

Hi, I have a date/time field in my file. I have to search in all the records and append a timestamp to it, if the timestamp is missing in that field. Is there a possible awk solution for this? Field date format File1 ==== 1|vamu|payer|2007-12-02 02:01:30|bcbs|... (5 Replies)
Discussion started by: machomaddy
5 Replies

6. Shell Programming and Scripting

incrementing the variable name along with the data?

Hello folks. I am trying to increment my variable names to match a counter that is to be used later on... Basically, i have a for loop that lists directories (for example TEST_OS DVP_OS PROD_OS ) but this loop is not static, it may contain 3 directory once and the next run 5 directories. I... (6 Replies)
Discussion started by: Stephan
6 Replies

7. Shell Programming and Scripting

awk script to split field data

Hi Experts, I have a Input.txt document which contains data fields seperated by tabs. There are 4 fields totally Named UNIQUE, ORDER, CONTACT and WINS. The UNIQUE field contains unique ID and the CONTACT field contains data seperated by comma in some records. I am looking to write an awk script... (12 Replies)
Discussion started by: forumthreads
12 Replies

8. Shell Programming and Scripting

How to insert data befor some field in a row of data depending up on values in row

Hi I need to do some thing like "find and insert before that " in a file which contains many records. This will be clear with the following example. The original data record should be some thing like this 60119827 RTMS_LOCATION_CDR INSTANT_POSITION_QUERY 1236574686123083rtmssrv7 ... (8 Replies)
Discussion started by: aemunathan
8 Replies

9. Shell Programming and Scripting

Sort data by a DDMMYYYY field

I have a CSV file which I have to sort it by a field with DDMMYYYY format, since I'm not a unix specialist, how is the easiest way to do this? Sample data 30062008,432120,A,5001,A,201,Z ,2,MXN 31092008,432121,B,4001,B,101,Z ,2,MXN 05112008,432122,C,2001,C,51,Z ,2,MXN... (2 Replies)
Discussion started by: martinezjorge
2 Replies

10. UNIX for Dummies Questions & Answers

can anybody help me out in writing the script for incrementing the specific field

can anybody help me out in writing the any script (awk,shell or perl script) for incrementing the specific field highlighted below /{/data/{/assetMetricsList//{1]/dailyCount,........./{/data/{/assetMetricsList//{100]/dailyCount It should be in below format in oneline seperated by commas ... (1 Reply)
Discussion started by: swapnak
1 Replies
Login or Register to Ask a Question